Integrating Computer Vision & Blockchain for Enhanced Saffron Evaluation: A Focus on Filament Curvature Assessment Mohammad Rowhani Sistani1,2,3 , Pierluigi Gallo1,4 and Maria Timoshina2 1 University of Palermo, Italy 2 SEEDS s.r.l., Italy 3 University of Camerino, Italy 4 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni, Italy Abstract In this paper, we present a study on the curvature analysis of saffron filaments using computer vision. The goal is to develop a reliable method for detecting altered saffron by analyzing the curvature of saffron filaments in captured pictures using image processing. Saffron can be altered through processes such as pressing and ironing, one of the usual frauds on the saffron supply chain. We explore the integration of blockchain technology in the saffron supply chain to enhance traceability and ensure economic and societal sustainability. Keywords Blockchain, Saffron, Computer Vision, Supply chain, Image processing 1. Introduction Saffron, the most expensive spice in the world, derived from the Crocus sativus flower, is a highly sought-after spice known for its distinct flavor, aroma, and vibrant color. The harvesting and processing of saffron involve intricate methods, and the quality of saffron is often determined by the characteristics of its filaments [1]. Saffron, often referred to as ”red gold” holds a special place not only in the culinary world but also in traditional medicine and cultural practices. Its scarcity, along with the intensive harvesting process, contributes to its high market value. Undoubtedly, the primary factor driving its value is the extensive requirement for manual labor at constantly increasing costs, compressed into a limited number of days and just a few hours each day. Additionally, post-harvest, a dehydration treatment is essential to transform the stigmas of Crocus sativus L. into saffron spice. This dehydration process results in the stigmas losing approximately 80% of their original weight [2]. Another reason for the high price and value of saffron is its low cultivation area which leads to its low production in the world. Iran, Spain, and the Republic of India are the largest producers 6th Distributed Ledger Technologies Workshop (DLT2024), May, 14-15 2024 – Turin, Italy Envelope-Open Mohammad.rowhanisistani@unipa.it (M. R. Sistani); pierluigi.gallo@unipa.it (P. Gallo); maria.timoshina@seedsbit.com (M. Timoshina) © 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR ceur-ws.org Workshop ISSN 1613-0073 Proceedings of saffron in the world, collectively responsible for around 90% of global production, equivalent to approximately 300 tons annually [3]. The majority of saffron production in India is concentrated in the Jammu and Kashmir region. Currently, Kashmiri saffron encounters challenges in the selling process, primarily stemming from issues such as the absence of standardization, certification, and quality assurance. Adulteration emerges as a significant concern contributing to a decline in saffron demand, it leads to a deterioration in its overall quality, reduces customer trust, and causes health problems for consumers. In our study, we delve into how computer vision can be a game changer for identifying the characteristics of saffron. The fundamental concept involves endowing machines with the ability to recognize what is apparent to humans, particularly in inspecting saffron filaments and distinguishing its color, length, and straightness. The objective entails instructing com- putational systems to visually perceive and interpret images or videos akin to an experienced specialist, albeit with the precision and steadfast attention characteristic of algorithms [4]. By leveraging image processing, a key component of computer vision, we can notably enhance both the precision and efficiency of the saffron evaluation process. This analysis, a facet of image processing, enhances the reliability and speed of quality assessment by reducing noise, improving contrast, and extracting pertinent features from the saffron imagery. Our objective is to implement a repeatable, automatic, reliable, and foolproof system resilient against errors and human oversight, capable of promptly assessing the quality of saffron. This effort is aimed at maintaining standards and providing assurance to consumers regarding the authenticity of the product [5]. The pervasive challenge of ensuring product authenticity and data integrity in the face of manipulation calls for robust solutions. In response to this, technology emerges as a valuable tool. Blockchain offers a transparent, traceable, and decentralized ledger system that is tamper- resistant by design. This secure framework holds particular promise for enhancing transparency and ensuring the traceability of high-value goods such as saffron. Products like saffron are susceptible to counterfeiting, both in terms of physical products and associated data throughout the saffron supply chain. By integrating blockchain into the saffron supply chain, we can significantly reduce the risk of fraud and protect the data from being altered illicitly. The technology not only supports secure transactions but also paves the way for trusted decision- making among multiple stakeholders in the supply chain, industry, and consumers. Blockchain technology transforms the concept of a shared registry into a tangible reality across diverse application domains, spanning from cryptocurrency to potential implementations in decentralized, resilient, and trustworthy decision-making within multi-stakeholder industrial systems. Particularly notable is its utilization to enhance sustainability, such as establishing a high-trust supply chain, which impacts economic viability, environmental preservation, and social equity, which are the primary focus of exploration in this study. 2. Related works A diverse range of research and innovation fields offers a wealth of novel perspectives, sophis- ticated techniques, and cutting-edge technological developments. This section explores the reduced human errors, interferences and Blockchain frauds Computer Network Vision Sustainability Traceability and Transparency collecting features of information saffron from farm to strands fork Saffron Products Figure 1: The integration of three combinations of saffron, computer vision and blockchain current body of knowledge on saffron analysis in related works, several projects in various image processing applications, computer vision applications in food quality assessment, and the revolutionary potential of blockchain technology in supply chain management. These linked works demonstrate the dynamic nature of research in these fields and provide the framework for comprehending the complex strategies and solutions used in various domains. 2.1. Saffron Analysis Literature This paper extends a previous work on computer vision and blockchain for saffron in [6]. The paper focuses on enhancing the transparency, traceability, and quality control of the saffron supply chain through the integration of blockchain technology and computer vision, introducing objective quality assessment focusing on filament color and length moving beyond subjective human assessment. The system validates data with a blockchain network on Multichain to ensure a secure and tamper-resistant tracking mechanism across the supply chain. The present paper extends that work by analysing curvature of filaments and moving forward towards a methodology for saffron identification. In [7] the authors propose a saffron quality classification based on its aroma. The paper addresses a critical issue in the saffron industry, where the high value of saffron makes it suscep- tible to adulteration. Adulteration methods, such as adding cheaper materials or immersion of saffron in substances like honey or oils, pose challenges for both spice industries and consumers. The paper introduces an innovative approach utilizing an electronic nose system with metal oxide semiconductor sensors for detecting saffron adulteration. The electronic nose captures aroma fingerprints, and the data are analyzed using principal component analysis (PCA) and artificial neural networks (ANN). The work in [8] offers significant insights into theme of saffron adulteration detection high- lighting such methods as 1H NMR spectroscopy and multivariate data analysis. It underscores the absence of a robust method to distinguish pure high-grade saffron from adulterated samples, motivating the study. The paper asserts that the combination of 1H NMR spectroscopy and multivariate data analysis serves as a potent approach for detecting saffron adulteration. This method provides a rapid, minimally invasive, and comprehensive detection tool but spectroscopy is not available at customers’ premise neither in many industrial environments. 2.2. Image Processing Benefits The research on the relationship between computer vision and food quality assessment is particularly relevant to our analysis. In [9] it is listed a range of studies and applications demonstrating computer vision technol- ogy’s transforming power in the food sector. The volume delves into various approaches and strategies employed in utilizing computer vision to assess food product quality, from dairy and meat to fruits and vegetables. The authors highlighted technical solutions and methodologies including the use of computed tomography and magnetic resonance imaging in food science, including their ability to provide detailed internal images of food products. This methodology is useful for studying foods’ internal structure, such as salt distribution in dry-cured ham or fat in meats. MRI, with its excellent renditions of soft materials, is suitable for visualizing most food objects, monitoring dynamic changes as foods are processed, and characterizing the physical state of water in frozen corn, among other applications. The work describes pre-processing techniques for detecting food attributes to improve image quality before segmentation. It offers various segmentation techniques based on thresholds, regions, gradients (edge detection), and classifications segmentation. Techniques such as noise removal (using linear and median filters) and contrast enhancement (through histogram scaling and equalization) are discussed. The authors stress the fact that pre-processing steps are crucial for achieving accurate segmentation results in food quality evaluation and that different types of food images may require different segmentation techniques for optimal results. In our paper we focus on computer vision tech- niques that can be potentially taken with low-cost devices, eventually with a smartphone and integrate this with blokcchain and smart contracts. 2.3. Blockchain in Supply Chain Management After exploring the importance and capabilities of image processing in data visualization, the focus now shifts to another critical aspect of modern technology: blockchain in supply chain management. A recent contribution to this field is evident in the paper ”A Blockchain-Based System for Agri-Food Supply Chain Traceability Management” by [10], which introduces a comprehensive model for a blockchain-based agri-food supply chain traceability system. While image processing enhances the ability to analyze and interpret visual data, blockchain technology offers a decentralized and transparent framework for tracking and verifying the authenticity and integrity of products as they move through the supply chain. Embracing Hyperledger Fabric as its framework, the proposed system leverages a permissioned blockchain, offering a scalable and distributed solution tailored to the specific needs of the agri-food industry. The system uses smart contracts to automate supply chain operations, allowing for seamless registration of product types, batch creation, and ownership transfers among participating organizations. The integration of rule-based mechanisms further enhances the system’s capabilities, enabling the implementation of quality control measures to ensure adherence to predefined parameters. The significance of this paper lies in its practical use cases, illustrating the successful automation of supply chain management and the maintenance of transparent and immutable traceability information. The presented scenarios, ranging from ideal operations to alternative pathways with challenges, underscore the adaptability and robustness of the proposed model. As a valuable addition to the literature on blockchain applications in agri-food supply chains, this paper lays the groundwork for more sophisticated rule engines and performance evaluations, signalling a promising trajectory for future advancements in the field. The literature review highlights the diverse range of research efforts to address challenges in saffron quality assessment, spanning from innovative approaches in image processing to utilising blockchain technology for supply chain integrity. These studies underscore the multidisciplinary nature of saffron quality research and the significance of technological advancements in ensuring the authenticity and quality of this prized spice. 3. Saffron cultivation, classification and market In this section, we aim to delve into the various facets of saffron production, distribution, and classifications. We also aim to expound upon the predominant global locations where saffron cultivation is prolific. Furthermore, our discourse endeavours to elucidate the diverse categories of saffron and shed light on the key stakeholders within the saffron supply chain. Saffron, known as ”the red gold”, is a valuable plant and one of the most expensive cash crops worldwide [11]. With a history spanning over 4000 years, it has traditionally been used for its tonic and antidepressant qualities in medicine [12]. Derived from the dried red stigmas of the Crocus sativus L. flower, saffron is not only used to enhance the colour, flavour, and aroma of various dishes such as ’paella’ in Spain, ’Milanese risotto’ in Italy, and ’Lussekatter’ buns in Sweden, it is also gaining popularity in the food industry for its health benefits. In the modern context, saffron’s inclusion in diets is on the rise, driven by its perceived positive impact on human health, making it particularly appealing to consumers [13]. The world’s leading saffron producers include Iran, Greece, Morocco, Spain, and Italy. Addi- tionally, since 2015, Afghanistan, a neighbouring country to Iran, has also become involved in this market [14]. India also contributes to global saffron production, accounting for approxi- mately 5% of the total output. Most of India’s saffron production, about 90%, is concentrated in the Jammu and Kashmir region [15]. Experts in Iran classify saffron into three main categories: Sargol, Pushal, and Negin. This categorization is significant as it denotes distinct grades of saffron. Sargol, for instance, represents the top portion of the red filament and is characterized by a high concentration of crocin compounds, which contribute to saffron’s distinctive colour [16]. Crocin, functioning as the primary carotenoid, is accountable for the saffron colour. Picro- crocin, conversely, is the compound responsible for the bitter taste associated with saffron. As for Safranal, it is among the many molecules contributing to the distinctive aroma of saffron [17]. Appreciating the differences among various saffron types is essential for its effective utilization across diverse fields such as medicine, culinary, and textile production. The proliferation of adulteration on saffron or altered saffron poses a considerable challenge, Cultivated Area of Saffron (2010-2016) 100 Cultivated Area (ha 1000) 80 60 40 20 0 2010 2012 2014 2016 Year Figure 2: Saffron Cultivated from 2010 to 2016 [12]. Figure 3: Saffron Sargol grade (a), Saffron Negin grade (b), Saffron Pushal grade (c) as it undermines the integrity of the saffron market. Issues such as adulteration and mislabeling compromise the quality of saffron products and erode consumer trust. Detecting and addressing these fraudulent practices are crucial not only for safeguarding the economic interests of the saffron industry but also for ensuring consumers receive genuine, high-quality saffron with its intended health benefits and culinary attributes. Kashmiri saffron is encountering sales challenges due to the absence of standardization, certification, and quality assurance. Additionally, a lack of analysis and development further compounds the issues. Adulteration emerges as a significant concern, contributing to a decline in saffron demand and subsequently leading to a deterioration in its overall quality [3]. Based on a study conducted on saffron available in the Indian market, findings reveal that only 52% of the saffron samples are authentic, while 30% are of poor quality, and 17% are adulterated. This alarming trend of saffron adulteration is rapidly growing, presenting itself as a significant challenge and a form of white-collar fraud [18]. While accurate, traditional laboratory methods for detecting saffron adulteration are often inaccessible to many due to their complexity and the need for specialized equipment. Conse- quently, there’s a growing necessity for more user-friendly, cost-effective methods that can be utilized outside laboratory settings. These methods aim to empower consumers and small-scale vendors to verify the authenticity of saffron using a camera cellphone or other functional daily tools, ensuring quality and safety in the market. The development of such methods is critical in combating the widespread issue of food fraud, specifically in the saffron industry, where the stakes are exceptionally high due to the spice’s esteemed status and economic value. Indeed, crocin, safranal, and picrocrocin are vital components that determine saffron quality. Global standards stipulate that these compounds, along with saffron’s appearance, dictate its overall quality [19]. This article aims to empower users to discern potential saffron fraud by addressing these components. Various factors can influence the quality of saffron, and temperature is one of them. Several research studies have proven that heat has many negative effects on the vital components of saffron, such as crocin and safranal. Exposure to normal to high temperatures, especially those exceeding 60 degrees Celsius, can degrade crocin content and destroy other vital components of saffron [20, 21]. Figure 4: Normal saffron filaments (a), Pressing and heating the saffron filaments with steam (b), manipulated saffron with no nutritional value (c). One prevalent form of saffron fraud, often referred to in the saffron market as ”Indian saffron” or ”ironed saffron,” involves using a steam press machine. This method involves pressing saffron strands between two heated fabric plates, exposing saffron to steam. The goal is to straighten the saffron filaments and increase their length. However, this fraudulent practice damages the plant tissue and alters the saffron’s appearance characteristics, which are crucial determinants of its quality. Furthermore, the process results in the loss of essential compounds such as crocin, safranal, and picrocrocin, rendering the final product devoid of nutritional value. 4. Blockchain for saffron quality and sustainability The potential of blockchain technology to enhance quality control in the agri-food supply chain is increasingly recognized. Its immutable and decentralized ledger system offers unparalleled traceability and transparency, addressing key challenges within the industry. By tracking agricultural products from farm to fork, blockchain ensures each process step is documented and verifiable. This level of traceability is crucial for verifying the authenticity of food items, enabling real-time monitoring of manufacturing, processing, and delivery phases. The current challenges in agri-food quality assurance, such as adulteration and lack of traceability, are significant hurdles to ensuring food safety and consumer trust. Adulteration, the deliberate addition of inferior materials, is a common issue in the food industry, compromising the quality and safety of products. Similarly, the lack of a transparent and traceable supply chain makes it difficult to pinpoint the origin and handling of food products, leading to potential health risks and loss of consumer confidence. Blockchain technology addresses these challenges by providing a secure and transparent way to record and verify each transaction within the supply chain. The supply chain evolves into a more interconnected framework in a blockchain-enabled system. Every transaction recorded on the blockchain becomes accessible to every member within the network. This transparency improves the ability to track products, fostering greater confidence in the entire process [22]. Blockchain technology offers a multitude of solutions to enhance traceability and transparency in the saffron supply chain, as well as in other food product supply chains. One of these solutions is MultiChain platform or Hyperledger Fabric, the use of MultiChain platform, a permissioned blockchain platform, is crucial. It creates a secure and controlled environment, ideal for scenarios involving a network of known and trusted organizations. This aspect of the system ensures that sensitive supply chain data is managed securely, maintaining the integrity of information across various stakeholders. Additionally, using smart contracts to automate supply chain operations represents a signifi- cant innovation. The smart contracts, executed within the blockchain, automate transactions and processes, enhancing the efficiency and reliability of the supply chain management. This automation is particularly effective in reducing human error and increasing the speed of oper- ations, providing a robust mechanism for handling complex supply chain workflows. In the saffron supply chain, where consumers may lack the necessary information to recognize the qualities and distinguish between different types of saffron, the use of automatic systems such as IoT sensors or computer vision helps to record information with complete details accurately. Such validation ensures that the products adhere to the regulatory requirements and quality standards, thus enhancing the food supply chain’s overall quality control and safety. These elements collectively contribute to creating a more efficient, secure, and reliable agri- food supply chain management system, representing significant advancements in leveraging blockchain technology for enhancing traceability and quality assurance in the food industry. Farmer Farmer Records cultivation data IOT Sensors IOT Sensors Sends data to blockchain Blockchain Blockchain Platform Platform Immutable & Transparent Stores data security Ledger MultiChain MultiChain Platform Platform Ttriggers smart contract Smart Smart Contract Contract product history Automates Transactions VVerifies product quality Accesses Quality Quality Control Control Ensures Standards & Safety Approves and forwards products Distributor Distributor Distributes verified products Retailer Retailer Sells to customers Customer Customer Figure 5: Actors of the saffron supply chain and blockchain platform. 5. Digital Technologies Computer vision technology offers multifaceted applications, ranging from noise reduction and object removal in images to facial recognition and database searches for identifying individuals. This advanced technology is crucial in mitigating human diagnostic errors, particularly in contexts such as saffron analysis, where intricate details within each filament must be accurately assessed and differentiated. These advancements in image processing algorithms, particularly when combined with tools like OpenCV and MATLAB, offer a framework for the classification and grading of saffron. The proposed algorithms can discern subtle differences in saffron samples, aiding in quality control and fraud detection in the saffron industry. Image processing involves defining a two-dimensional function, 𝑓 (𝑥, 𝑦), where 𝑥 and 𝑦 represent spatial coordinates, and the amplitude of 𝑓 at any pair (𝑥, 𝑦) is the image intensity or grey level. When 𝑥, 𝑦, and amplitude values are finite and discrete, the image is termed a digital image. Digital image processing, carried out by a computer, involves manipulating these finite elements. Computer vision, a branch of artificial intelligence and image processing, focuses on computer interpretation of real-world images. It combines low-level image processing (e.g., noise removal, contrast enhancement) with higher-level pattern recognition to identify image features [5]. In the field of agri-food technology, the creation of image data processing systems is an important advancement. These systems greatly lessen the need for laborious and possibly arbitrary manual inspection by automating the analysis process. They can accurately and reliably identify and categorise characteristics like saffron appearance differences and fraudulent product manipulations. This improves agricultural productivity and sustainability by enabling Measurement Filaments and calssified distribution in 3 types of saffron Calculate the Remove Examining the make PDF and CDF for consider Image Image Image length oversize results for 3 each types of saffron 3 types Noise convert to edge and width of and unuseful quality groups of to show distribution of of saffron Elimination binary image detection filaments data saffron filament length Data input Data output Collection Pictures Collection Collection of Saffron checking the curvature of saffron filaments to detect the counterfeit of pressed saffron Receive data Calculate the Save the Creating a classification Checking the Statistical check of the Making a final from the width ratio degree of by examining the length and degree of probability Image Processing previous the length of curvature of saffron threshold diagnosis width of the curvature process filaments strings in each type of saffron Data input Data output Collection Collection Checking the color of saffron filaments to determine the quality Image Calculate the consider Image Image detect red give result and make convert to detect yellow percentage of 3 types Noise segmentation color a graph for percentage identify color color percentage each color compared of saffron Elimination detection percentage of red and yellow color distinctions to each other Data input Data output Collection Pictures Collection Collection of Saffron Figure 6: Image processing real-time monitoring and decision-making and ensuring more objective results. The development of mobile or portable devices utilizing image processing technology for on-the-spot quality assessment of saffron represents a significant advancement. This technology empowers vendors and buyers in markets by providing immediate, accurate assessments, reduc- ing the risk of adulteration, ensuring fair pricing, and offering the opportunity to identify real quality saffron in a user-oriented way without the need for laboratory equipment. Additionally, it facilitates recording information throughout the saffron supply chain by all stakeholders in- volved. Furthermore, integrating such technology in the saffron market streamlines the quality assurance process and enables the submission of data gathered from these algorithms onto the blockchain network. This integration ensures the retention and preservation of accurate data on a transparent network. 6. Methodology and Data This research introduces an innovative methodology for the computational analysis of saffron filament curvature, diverging from traditional quality assessment methods. The approach combines computer vision’s precision with MATLAB and OpenCV’s analytical power to offer a groundbreaking way of evaluating saffron quality through its filament curvature. A compre- hensive dataset of saffron filament images is compiled from various authentic sources, ensuring a wide range of curvature variations. These images are meticulously selected to represent different grades and conditions of saffron, providing a robust foundation for the analysis. The images undergo a sophisticated processing pipeline, which utilizes advanced filtering and segmentation techniques; the individual filaments are isolated from the image background, focusing on their unique curvature attributes. A custom-built algorithm is developed to analyze and quantify the curvature of the saffron filaments. This algorithm leverages the capabilities of (a) (b) Figure 7: The adulterated saffron after heat and to sift (a), the normal saffron as same quality before heat (b) MATLAB and OpenCV to detect subtle curvature differences for quality assessment. The curva- ture data extracted from the algorithm undergoes statistical analysis to establish correlations between filament curvature and saffron quality to detect normal saffron without fraud. This analysis aims to identify patterns and thresholds that can be used to identify saffron objectively. 6.1. Data Collection For the initial development of the algorithm and image processing, standard saffron images were captured in a laboratory using common mobile cameras with typical noise levels. This approach was chosen to make the algorithm easily usable for everyday users. During this data collection phase, specific guidelines and methods were established, leading to the following steps: 1. Photos of adulterated saffron, high-quality saffron and lower-grade saffron were taken to form the first set of samples. In this set, the saffron with the longest filaments represented the highest quality and the shortest had the lowest quality. 2. The saffron was laid out on a white sheet of paper, and the camera was positioned 20 cm away from the plate. 3. Each saffron sample weighed exactly one gram. 4. To capture diverse images, each identical sample was photographed ten times. The paper was shaken between each shot to rearrange the saffron strands in various orientations. 5. The same saffron filaments were then crushed to simulate low-quality saffron for addi- tional photography, forming the second set of samples. However, the adulterated saffron samples were left as is for this process. 6.2. Analysis of Filament Size This section focuses on a technique to enhance the visibility of saffron filaments in images. The method begins by converting images to grayscale and creating a binary representation to differentiate between black and white areas. The process then involves measuring the length and thickness of the saffron filaments. Specific criteria are used to select filaments for analysis, and their lengths are plotted in histograms. This analysis is further applied to saffron samples of different quality levels, allowing for an evaluation of saffron quality. The Cumulative Distribution Function (CDF) is employed in this script to draw comparisons in saffron quality across various categories. This part of the study delves into three distinct quality categories of saffron: ’A’, ’B’, and ’C’. For each category, the research meticulously examined ten images of saffron filaments. A key analysis component was using data visualization techniques, particularly histograms, to illustrate the distribution of filament lengths across each quality category. Cumulative Distribution Functions (CDFs) provided additional insight into the range and variability of filament lengths. The methodology also entailed calculating and visually representing the proportions of red and yellow colours in the saffron filaments, which served as an objective indicator of colour composition. The colour composition of saffron filaments is crucial in determining their potency and general quality, so it is evaluated with special attention. Notably, one of the important factors in detecting saffron quality is that higher-quality saffron filaments are frequently linked to a richer red colour. This relationship arises from the carotenoid pigment crocin, which gives saffron its characteristic red colour and directly correlates with strength and quality. Conversely, yellow segments in saffron filaments, often found towards the ends of the strands, indicate lower quality [6]. Bright red indicates a high crocin concentration, which indicates superior colouring power for high-quality saffron. Furthermore, the analysis involved isolating objects based on their diameters to understand the correlation between size and quality. This classification enabled an exploration of filament length distributions within each size class, using histograms and CDFs to assess cumulative probability trends and the proportion of filaments within specific length ranges. After the initial inspection and grading of saffron quality, the curvature degrees of saffron filaments are calculated using the previous data of the filaments’ length and diameter by creating a mathematical ratio of width to length. Finally, the algorithm identifies the filaments of each group of saffron as saffron adulteration if the curvature value is less than normal. 7. Final Remarks and Future Directions Blockchain application, developed on the MultiChain platform, streamlines the management of the saffron supply chain. Leveraging Bitcoin’s underlying technology, MultiChain enables swift blockchain application development. It organizes data in distinct streams based on user and year, each containing user-generated data blocks or transactions. The application offers three types of data streams - public, business, and reserved - tailored to different privacy needs. User data is distributed across multiple blockchain nodes to enhance stability and security. Additionally, users can utilize dedicated nodes, ensuring data redundancy. A notable aspect of our system is the use of ”smart filters,” which serve as a more efficient alternative to conventional smart contracts. These filters assess data before it’s added to the blockchain, deciding whether to log it or tag it with special identifiers. For example, saffron meeting certain criteria can be tagged as ”organic.” Smart filters also validate existing data when added to the blockchain, allowing 1 1 0.9 0.9 0.8 0.8 Cumulative Distribution Cumulative Distribution 0.7 0.7 0.6 0.6 0.5 0.5 0.4 0.4 0.3 0.3 0.2 0.2 High Quality High Quality Middle Quality 0.1 Middle Quality 0.1 Low Quality Low Quality 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0 0.1 0.2 0.3 0.4 0.5 Thickness-to-Length Ratio (Curvature) Thickness-to-Length Ratio (a) (b) Figure 8: CDF of ratio width to length three types as each group (a), CDF of ratio width to length thirty pictures of three types saffron (b) 1 1 0.9 0.9 0.8 0.8 Cumulative Distribution Cumulative Distribution 0.7 0.7 0.6 0.6 0.5 0.5 0.4 0.4 0.3 0.3 0.2 Type C 0.2 Type B Short Filaments Type A Middle Filaments 0.1 0.1 Long Filaments 0 0 0 50 100 150 200 250 0 50 100 150 200 250 Filaments Length [mm] Filament Length [mm] (a) (b) Figure 9: CDF of three types of saffron and their intersection with a pre-defined threshold (a), CDF of length thirty pictures of three types saffron (b) for ongoing quality checks. All stakeholders in the saffron supply chain, including farmers, producers, sellers, and buyers, contribute data to the blockchain. This collaborative approach creates a detailed product history, ensuring complete traceability. In the specific case of the saffron supply chain, smart filters evaluate the length and colour of saffron strands through Algorithm 1 Algorithm for detecting saffron adulteration ℎ𝑒 ← rgb2gray(image) ▷ Convert RGB image to grayscale 𝑏𝑤 ← im2bw(image) ▷ Convert image to binary image 𝑏𝑤 ←∼ 𝑏𝑤 ▷ Invert binary image 𝑠𝑡𝑎𝑡𝑠 ← regionprops(binary_image) ▷ Find contours and shape properties 𝑐𝑐 ← bwconncomp(𝑏𝑤) ▷ Find and count connected components [𝑜𝑢𝑡𝑀𝑎𝑥, 𝐿𝑀] ← Feret(𝑐𝑐) ▷ Get shape stats and filter out outlayers 𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑙𝑒𝑛 ← outMax.MaxDiameter(1 ∶ maxLabel) ▷ Get maximum diameters for each filament 𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑡ℎ𝑖𝑐𝑘 ← outMin.MinDiameter(1 ∶ maxLabel) ▷ Get minimum diameters for each filament [𝑜𝑢𝑡𝑀𝑖𝑛, 𝐿𝑀] ← Feret(𝑐𝑐) ▷ Compute Feret properties 𝑣𝑎𝑙𝑖𝑑𝑝𝑜𝑠𝑙𝑒𝑛 ← find(𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑙𝑒𝑛) ▷ Find lengths of valid filament 𝑣𝑎𝑙𝑖𝑑𝑝𝑜𝑠𝑡ℎ𝑖𝑐𝑘 ← find(𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑡ℎ𝑖𝑐𝑘) ▷ Find thicknesses of valid filament 𝑣𝑎𝑙𝑖𝑑𝑝𝑜𝑠𝑡ℎ𝑖𝑐𝑘 ← find(𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑡ℎ𝑖𝑐𝑘) ▷ Calculate width to length ratio on each 𝑣𝑎𝑙𝑖𝑑𝑝𝑜𝑠𝑡ℎ𝑖𝑐𝑘 ← find(𝑓 𝑖𝑙𝑎𝑚𝑒𝑛𝑡_𝑡ℎ𝑖𝑐𝑘) ▷ Classified the saffron normal and abnormal according threshold image analysis and assign quality marks based on predefined standards. In this research, we used the Multichain platform to evaluate the methodology and feasibility of traceability and quality verification in the saffron supply chain. The blockchain can efficiently handle the requested transaction volumes, the number of which depends on the statistical compression of the row data. Time to run the CV algorithm makes writing on the blockchain processing time, as the requirements are not strict. We consider one image per second of the conveyor belt and then analyze 60 images; this implies one writing on the blockchain per minute, showcasing its scalability and robustness. These performance metrics fit the blockchain’s capability to provide real-time traceability and immutable record-keeping in a high-demand market like saffron. Our blockchain implementation uses MultiChain technology, which is tailored to facilitate the secure and efficient management of the saffron supply chain by integrating its data ingestion with the capability of Computer Vision. Our system’s architecture is built around a tailored consensus algorithm through a smart filter derived from MultiChain’s inherent multilateral mining approach. This consensus model is engineered to distribute control equitably among all participating nodes, ensuring no single entity can dominate the decision-making process. Additionally, it enhances the robustness of our blockchain-based platform by preventing any single point of failure, which is crucial for maintaining continuous operations through the saffron supply chain. This setup ensures real-time transaction verification and consistent updates across all nodes. Furthermore, we have developed specific smart filters to enhance the traceability and the automation level of the saffron quality verification. These smart contracts streamline operations such as batch tracking, quality certification, and payment processes, enhancing the saffron market’s operational efficiency and transparency. 7.1. Create and deploy Redgold Blockchain on Multichain The initial step in establishing the Redgold blockchain involved creating and deploying the first node onto the network. For this task, we utilized MultiChain and incorporated various stakeholders of the saffron supply chain, ranging from farmers to customers. This process included installing MultiChain on the primary node and configuring the genesis block, which serves as the foundation of the blockchain. After the creation, the Redgold blockchain was deployed by starting the blockchain on the primary node, we created other permissions and rules on the network. Additional nodes were connected to the Redgold blockchain network by installing Multichain on other machines and using the connection information provided by the primary node. This step is crucial for creating a decentralized network where multiple participants can interact with the blockchain. For each participant in the supply chain, a unique blockchain address was generated. These addresses represent farmers, logistics providers, quality control labs, distributors, retailers, and customers. Streams were created on the Redgold blockchain to represent categories of data and trans- actions relevant to the supply chain. Each stream was assigned to an aspect of the supply chain, such as production data for farmers to submit all data from the producing step, like the Origin area of the product, and other streams like logistics, quality control, distribution, retail, and customer feedback. Permissions were allocated to each participant, allowing them specific interactions with the streams. The permissions include writing, reading, and sending transactions within assigned streams. This granularity in permission settings ensures data integrity and access control within the blockchain network, as explained in Algorithm 2. 8. Conclusion This research provides a methodological approach to saffron quality assessment, blending computer vision’s objectivity with blockchain technology’s transparency. Our study demon- strates the effectiveness of using a quality metric and algorithm for analyzing the curvature of saffron filaments in quality assessment to detect counterfeit saffron. This method addresses a significant gap in quality control practices, predominantly focused on colour, aroma, and chemical composition. By introducing a reliable and accessible way to evaluate saffron quality, this approach em- powers producers, suppliers, and consumers to ensure the authenticity and purity of saffron. Integrating blockchain technology into the saffron supply chain is a pivotal advancement in the digital domain but still requires special attention to guarantee correspondence with the physical one. In addition to using decentralized and secure digital platforms, we suggest to use computer vision to monitor saffron during the whole supply chain, requiring a methodology that automatically extract info from filaments and compare them over time. Future research should focus on the potential of the proposed integration of blockchain and computer vision also to use visual features as markers that fingerprint the product; in order to identify it beyond classification. References [1] J. P. Melnyk, S. Wang, M. F. Marcone, Chemical and biological properties of the world’s most expensive spice: Saffron, Food Research International 43 (2010) 1981–1989. doi:10. 1016/J.FOODRES.2010.07.033 . [2] M. Carmona, A. Zalacain, J. E. Pardo, E. López, A. Alvarruiz, G. L. Alonso, Influence of different drying and aging conditions on saffron constituents, Journal of Agricultural and Food Chemistry 53 (2005) 3974–3979. URL: https://pubs.acs.org/doi/full/10.1021/jf0404748. doi:10.1021/jf0404748 . [3] J. Amin, A. Selwal, A. Sabha, Saps: Automatic saffron adulteration prediction systems, research issues, and prospective solutions, Proceedings - 2021 4th International Conference on Computational Intelligence and Communication Technologies, CCICT 2021 (2021) 64–71. doi:10.1109/CCICT53244.2021.00024 . [4] R. Szeliski, Computer Vision: Algorithms and Applications, Springer, 2020. URL: https: //books.google.it/books?hl=en&lr=&id=QptXEAAAQBAJ&oi=fnd&pg=PR9&dq=whats+ computer+vision&ots=BNuaz0Ywsm&sig=BQRLhJFePZhrJ5Vl894pGUkwyTY&redir_esc= y#v=onepage&q&f=false. [5] S. Nagabhushana, Computer vision and imaging processing (2006) 206. URL: https://books.google.com/books/about/Computer_Vision_and_Image_Processing.html? id=eSu5I9pU3rUC. [6] M. R. Sistani, P. Gallo, M. Timoshina, Red gold traceability: computer vision and blockchain for saffron quality, BlockSys 2023 - Proceedings of the 5th ACM International Workshop on Blockchain-enabled Networked Sensor Systems (2023) 13–20. URL: https://dl.acm.org/ doi/10.1145/3628354.3629530. doi:10.1145/3628354.3629530 . [7] K. Heidarbeigi, S. S. Mohtasebi, A. Foroughirad, M. Ghasemi-Varnamkhasti, S. Rafiee, K. Rezaei, Detection of adulteration in saffron samples using electronic nose, International Journal of Food Properties 18 (2015) 1391–1401. URL: https://www.tandfonline.com/doi/ abs/10.1080/10942912.2014.915850. doi:10.1080/10942912.2014.915850 . [8] R. Dowlatabadi, F. Farshidfar, Z. Zare, M. Pirali, M. Rabiei, M. R. Khoshayand, H. J. Vogel, Detection of adulteration in iranian saffron samples by 1h nmr spectroscopy and multi- variate data analysis techniques, Metabolomics 13 (2017) 1–11. URL: https://link.springer. com/article/10.1007/s11306-016-1155-x. doi:10.1007/S11306- 016- 1155- X/FIGURES/7 . [9] M. Nixon, A. Aguado, Feature Extraction and Image Processing for Com- puter Vision, Academic Press, 2020. URL: https://books.google.it/books? hl=en&lr=&id=KcW-DwAAQBAJ&oi=fnd&pg=PP1&dq=computer+vision+ and+image+processing+projects+on+food+products&ots=11hw6mWx5S&sig= t-gz2dpxlIdr1I7DzI4DGhkILxY&redir_esc=y#v=onepage&q&f=false. [10] A. Marchese, O. Tomarchio, A blockchain-based system for agri-food supply chain trace- ability management, SN Computer Science 3 (2022) 1–21. URL: https://link.springer.com/ article/10.1007/s42979-022-01148-3. doi:10.1007/s42979- 022- 01148- 3 . [11] S. Leone, L. Recinella, A. Chiavaroli, G. Orlando, C. Ferrante, L. Leporini, L. Brunetti, L. Menghini, Phytotherapic use of the crocus sativus l. (saffron) and its potential applica- tions: A brief overview, Phytotherapy Research 32 (2018) 2364–2375. doi:10.1002/PTR. 6181 . [12] M. Shokrpour, Saffron (crocus sativus l.) breeding: Opportunities and challenges, Advances in Plant Breeding Strategies: Industrial and Food Crops 6 (2019) 675–706. doi:10.1007/ 978- 3- 030- 23265- 8_17 . [13] A. Kyriakoudi, S. A. Ordoudi, M. Roldan-Medina, M. Tsimidou, A functional spice, Austin J Nutri Food Sci 3 (2015). URL: www.austinpublishinggroup.com. [14] H. Mohammadi, M. Reed, Saffron marketing: challenges and opportunities, Saffron: Science, Technology and Health (2020) 357–365. doi:10.1016/B978- 0- 12- 818638- 1. 00022- 8 . [15] A. Kumar, M. Devi, R. Kumar, S. Kumar, Introduction of high-value crocus sativus (saffron) cultivation in non-traditional regions of india through ecological modelling, Scientific Re- ports 2022 12:1 12 (2022) 1–11. URL: https://www.nature.com/articles/s41598-022-15907-y. doi:10.1038/s41598- 022- 15907- y . [16] M. M. Moghadam, M. Taghizadeh, H. Sadrnia, H. R. Pourreza, Nondestructive classification of saffron using color and textural analysis, Food Science and Nutrition 8 (2020) 1923–1932. doi:10.1002/FSN3.1478 . [17] A. Bergomi, V. Comite, L. Santagostini, V. Guglielmi, P. Fermo, Determination of saf- fron quality through a multi-analytical approach, Foods 2022, Vol. 11, Page 3227 11 (2022) 3227. URL: https://www.mdpi.com/2304-8158/11/20/3227/htmhttps://www.mdpi. com/2304-8158/11/20/3227. doi:10.3390/FOODS11203227 . [18] A. M. Husaini, S. A. U. Haq, A. Shabir, A. B. Wani, M. A. Dedmari, The menace of saffron adulteration: Low-cost rapid identification of fake look-alike saffron using foldscope and machine learning technology, Frontiers in Plant Science 13 (2022) 945291. doi:10.3389/ FPLS.2022.945291/BIBTEX . [19] K. . Kour, D. . Gupta, J. . Rashid, K. . Gupta, J. . Kim, K. . Han, K. Kour, D. Gupta, J. Rashid, K. Gupta, J. Kim, K. Han, K. Mohiuddin, Smart framework for quality check and deter- mination of adulterants in saffron using sensors and aquacrop, Agriculture 2023, Vol. 13, Page 776 13 (2023) 776. URL: https://www.mdpi.com/2077-0472/13/4/776/htmhttps: //www.mdpi.com/2077-0472/13/4/776. doi:10.3390/AGRICULTURE13040776 . [20] Z. Khadfy, H. Atifi, R. Mamouni, S. M. Jadouali, A. Chartier, R. Nehmé, Y. Karra, A. Tahiri, Nutraceutical and cosmetic applications of bioactive compounds of saffron (crocus sativus l.) stigmas and its by-products, South African Journal of Botany 163 (2023) 250–261. doi:10.1016/J.SAJB.2023.10.058 . [21] S. Karasu, Y. Bayram, K. Ozkan, O. Sagdic, Extraction optimization crocin pigments of saffron (crocus sativus) using response surface methodology and determination sta- bility of crocin microcapsules, Journal of Food Measurement and Characterization 13 (2019) 1515–1523. URL: https://link.springer.com/article/10.1007/s11694-019-00067-x. doi:10.1007/S11694- 019- 00067- X/TABLES/4 . [22] M. L. Di Silvestre, P. Gallo, J. M. Guerrero, R. Musca, E. Riva Sanseverino, G. Sci- umè, J. C. Vásquez, G. Zizzo, Blockchain for power systems: Current trends and future applications, Renewable and Sustainable Energy Reviews 119 (2020) 109585. URL: https://www.sciencedirect.com/science/article/pii/S1364032119307932. doi:https: //doi.org/10.1016/j.rser.2019.109585 . Algorithm 2 Blockchain Setup for Saffron Supply chain Initialization: Create blockchain named Redgold Start Redgold in daemon mode Announce node connection details Address Generation: for each participant in {Farmer, Logistic, Lab, Distributer, Retailer, Customers} do Farmer: 1JcTSXmswoyBrZmdx4HJESPZFKk6uJTDD8w8iV Logistic: 1aSRzNR2QtfsYeFote84Tw3pu3oTY7maGcDq27 Lab for check and test quality: 1FqK5h47Xu2JyWJj6sme5WxaBQbxT57JZNGrUb Computer Vision (Quality check center): 1VEEk1anPgun4wPzYFhVEHpKRBnDgZ8BjrU8f3 Distributer: 1NM3ecdYadQjZmKipwoRM5i4XwNFvig1TtZyzB Retailer: 1AEELHd9uUsQMSFhPtrPkF5xcDHRFGzjYvqnZ4 Customers: 1WorygsvwuVxGAubXgPpJF2ECQP54SCZxgWG8k end for Stream Creation: for each stream in {Qualitycontrol1, Distributer1, Retail1, Customers1, Logistic1} do Create stream with write restriction: {Productiondata1: 04a9f5526f5ed0dbb6edb23048b9dde50288d347987e7be52398758aecbfc368} {Logistic1: 02bff25f6647242c166257a1249e5a537c0a2bc7fd4a6b987054e5567fa41ad1} {Quality Control1: acdf8a4d3e518e03c4f61c58b7b5ad137d5a0537bb206cc7dddfbaca0bc4045a} {Distributer1: 6937ee4c5441936386d3aacbab766ae87c04a09e542fcf9af0f48ce4b3b110b4} {Retail1: 934a518e178e222788d1b159de5b90a9f1aae3b3d0cc4c4aa9ed08ca633f48bd} {Customers1: ff91920028a8b0175f0c86eda185e68075ab2aa455c69e7366187ad28e5907a6} end for Permission Granting: for each participant and their respective stream do Grant write permission to participant for their stream Grant read permission to participant for their stream Grant send permission to participant Access: Farmer Write: 47890a61d5644753886ed0fa776ba8ab8aac9491559831ecbe2a8c926ab02ca8 Read: b57f88b70a53c61b73dbc74686b2537b04da8d7325e0c9bec20997885f6dee8f Send: 76654bdffdf6f3df036db9ab9c78ff87810ce93ebc06b9194deae1ce87819cb2 Logistic: Write: 7c521f520723d7501835b16f3e747e497d1074a4205e52328366fe337c210a56 Read: 8c695175fbda7bd6d6cb280ebf755d1e35b611969fdb7450a608666757e07a42 Send: cf9b34178f507ff62b361e1b366b5ed93d5f75191bb770bccd7ffb29b4627284 Quality Control: Write: 4ea81ebe2d4672697ae32748a89d0f2e088b67871fd3ee32d78d7fdc23911fb9 Read: bd3d90166df0a5dec4e4d34d01e3f8a3543e20f6fb55ead071356804e2d983be Send: 9df5ecc83a0e5ab6a46b80e86ef43f61e6808ece581dae18bc0bc35f89a4ae39 Distributer: Write: 16b7b3fd4b2da18fc199ed799aad7052a0a570592e5bedabce44b64e7b80f52c Read: 141b8982b4727245115e5749e0a286464a221329334c2804790d138a9be013d6 Send: 6d12ce82298497ca0cc1ad0966aaa99df9b28fae08f588f9fa7f6b100bfce4c8 Retailer: Write: 0932e6921806b52403574a1e1d2dbae7872a2e9172fddd57ece7f5870c0c8793 Read: 466c83b1d48e6cabad41eb85a36eddc32b0eb74104223f17f44d66081d8a5427 Send: 895a4150fe54cd8363cfa1ded2e04c81c5f50cad3bebd30c6b05906e12c5b13e Customer: Write: 13d1907cb471a00a59a8659787d36853178faaabcebd810945b4d8ff01d36f7c Read: 21655b7ab10c8d1e3cd77b07ac7e5d9e220a5c18f2e7207a7030b6d9d0e8ced5 Send: 1d8ad32e90cafc4ec4a8b1655978156ab26bfdf31aec464d8fa43717039c3638 end for