Cardamom Capsule Size and Surface Area Using Digital Image Processing Technique
Manual grading and sorting of cardamom spices require a long time and considerable resources. This research was carried out to contribute towards the use of machine vision technology in the grading of cardamom spices. In this regard, the utility of images captured by mobile devices was assessed using digital image processing techniques. The color images of cardamom capsules were acquired using an Apple iPhone 7 in the first place. The geometric features (major diameter, minor diameter, surface area, and perimeter) of the samples were calculated using MATLAB algorithms. The pixelated units were converted into SI units (mm). The predicted values of the parameters were compared with the actual values. The goodness of fit was assessed using the coefficient of determination (R2), which was found to be 0.92, 0.88, 0.95, and 0.97 for the major diameter, minor diameter, surface area, and perimeter of the samples, respectively. In terms of mean absolute percentage error (MAPE), the accuracy of the model was found to be 95.64%, 94.74%, 95.32%, and 97.81% for the predicting major diameter, minor diameter, surface area, and perimeters of cardamom capsules, respectively. These results indicate that mobile images could be successfully incorporated in machine vision technology for the effective grading of cardamom capsules.
Materials and Methods
Cardamom (Elettaria cardamomum (L.) Maton) samples popularly known as elachi were collected. A total of 62 cardamom samples having different sizes were selected for this research. According to the Indian Standard specification for cardamom (IS: 1907–66), samples (crooked green category) were graded based on their physical color and size factor.
Major and minor diameter: The major and minor diameter were calculated manually using a vernier caliper, where the measurement range and accuracy of that vernier calipers were fixed around 0-130 mm and 0.03 mm, respectively. Generally, the major diameter of a cardamom capsule is defined as the distance between the apex and the basal ends, while the minor diameter is measured at the midpoint of the cardamom capsules. According to the grading requirement (Indian Standard specification for cardamom. IS: 1907–66. Indian Standards Institution, New Delhi-1) and maintain the consistency of measurement, we measured the minor diameter of cardamom samples along the midpoint.
Surface area:
The estimated capsule surface area was obtained by using graph papers graduated with one millimeter square grid lines. The capsule was placed on the graph paper sheet and the perimeter of the capsule was sketched by a pencil on the paper. Finally, the full and half square blocks of encircling the outline of the capsule were considered for surface area calculation by using the following equation.
Surface Area = NOC × AGP ……………. (1)
NOC = number of full and half-square blocks of outlined capsule AGP = area of each square block of graph paper
Perimeter:
The perimeter of a cardamom capsule was measured using a thin ribbon placed around the circumference of the cardamom capsule. The ribbon was then straightened, and the perimeter was recorded by putting the ribbon along the ruler scale.
Images acquisition system
There are many types of cameras for imaging a particular product. Despite the uses of digital cameras, camcorders, and PC-cams, the portable cellphone camera has also emerged as a potential imaging device. There have been several efforts that employed images that were not captured under structured specific lighting for illumination. The images of cardamom in this research were acquired by using an iPhone 7 device without flash under stationary conditions.
The phone was attached to a stick-shaped holder and the distance between the phone camera and object was 25 cm. Cardamom capsules were placed on a black cloth of laboratory bench. The camera lens was parallel to the bench surface ensured with a leveler. A fluorescent tube lamp of laboratory lighting was used for the illumination. The image’s resolutions were 768 × 1024 pixels each and were stored in a jpeg format. A circular blob of known dimensions was used as a reference for dimensional calibration in each image. Reference was also used to convert the pixel values of major diameter, minor diameter, surface area, and perimeter to SI units. Image processing system Image processing and analysis were carried out by using MATLAB (R 2018b). The processing system consists of cropping, conversion of RGB image to a grayscale image, contrast enhancement of grayscale image, image segmentation by Otsu thresholding method, and morphological operation (eroding and dilating). First, we cropped only the cardamom capsule. Then the RBG image was converted into a grey image by the rgb2gray command in MATLAB. To enhance the contrast of the grayscale image, adjust command was applied on grayscale images. After that, the Global thresholding method was applied to partition the image into two classes as foreground or cardamom surface (white) and background (black).
In Otsu thresholding methods, the threshold value is chosen automatically by the gray thresh function in MATLAB. Then image binarization (black and white image) was created from gray images by binarize algorithm using the selected thresholding level. Smoothing of the binary image was performed by imerode function which uses (morphological structuring element) diamond-shaped structuring element, where the distance from the structuring element origin to the points of the diamond is 1. The smoothed binary image is called a binary mask image. Finally, the image features like major, minor diameter, surface area, and perimeter were estimated using region props function from the outlined binary mask image of cardamom capsules. The measured features like major diameter, minor diameter, surface area, and perimeter were calculated in pixel units from the image processing technique. The major axis diameter of the circular blob (reference) was extracted in the same ways as cardamom capsules.
Performance analysis of prediction method
Developed the prediction model by linear regression analysis which shows the relationship between actual and estimated parameters of cardamom capsules. This regression analysis was done in Microsoft excel 2016 by plotting of estimated and actual values of cardamom capsules in the X and Y axis, respectively. The geometric features estimated by image processing approaches were evaluated based on the actual estimations. For the evaluation of the prediction model, several metrics were used to illustrate the differences between the estimated and actual values.
Results
The results of the comparison of the actual major diameter (measured by slide calipers) and estimated major diameter (measured by image processing) of sixty-two cardamom samples. The coefficient of determination (R2) for the major diameter of the cardamom was 0.926. The higher R2 values indicate a very close fit of the predicted model of the major diameter of cardamom samples with the actual measurement. The proportion of the variance in the estimating features to the actual measurements can be interpreted as the RMSE and MAPE values. The lower the RMSE and MAPE values indicate the closer prediction of image processing result with the actual measurement of major diameter in cardamom samples.
These errors may have come from the erosion and dilation of morphological operation during image segmentation. This estimated major (4.353% error) diameter using the image processing technique can be considered.
Minor diameter
The measured minor diameter of the 62 samples was plotted against their actual measurements as shown in figure 5. The coefficient of determination (R2) for cardamom in minor diameter was found to be 0.8838. However, Root means squared error (RMSE) and mean absolute percentage error (MAPE) was observed as 0.456 mm and 5.259% respectively.
Surface Area
The estimated surface area of the cardamom samples was plotted against the measured values. The coefficient of determination (R2), root mean squared error (RMSE), and mean absolute percentage error (MAPE) were determined as 5.650 mm2, and 4.687 % respectively. In this research, the surface area determination was carried out with considerable accuracy (95.32%) and no significant (Table 3) differences (p>0.05) between the means of the actual and measured surface area of cardamom capsules which suggesting the fact that the images captured by mobile devices can be used in machine vision technology.
Perimeter
The measured perimeters of cardamom samples were highly correlated with the actual measurement since the coefficient of determination (R2) was found at 0 .9762. The root mean squared error (RMSE) and mean absolute percentage error (MAPE) was found to be 1.238 mm and 2.183 %, respectively. The overall accuracy for determining the perimeter by using mobile images was therefore calculated to be 97.81% which is very satisfactory.
Conclusion
To contribute to the automated grading and sorting of cardamom spices, this research was carried out to quantify how images captured by mobile devices could be used for machine vision technology. For this, four features of cardamom samples, namely major diameter, minor diameter, surface area, and perimeter were estimated by image processing techniques using MATLAB. An algorithm was developed and employed on the images captured by an iPhone 7. This method was able to predict all the four geometric parameters of the samples. The results indicate that grading of cardamom samples based on their geometric features could be carried out by incorporating mobile images in machine vision technology in the future.
Citation:
Saha, K.K., Uddin, M.Z., Rahman, M.M., Moniruzzaman, M., Ali, M.A. and Oliver, M.M.H., 2021. Estimation of Cardamom Capsule Size and Surface Area Using Digital Image Processing Technique. Journal of the Bangladesh Agricultural University, 19(3), pp.398-405.