Rice Grain Quality Analysis
Rahul Basetti
Amar Honawad Anil Halagunaki
Department of Electronics and
Department of Electronics and Department of Electronics and
Communication
Communication Communication
Bldea’s V. P. Dr. P. G. Halakatti
Bldea’s V. P. Dr. P. G. Halakatti Bldea’s V. P. Dr. P. G. Halakatti
College of Engineering)
College of Engineering College of Engineering
Vijayapura 586103, India
Vijayapura 586103, India Vijayapura 586103, India
Email: rahulbashetti12@[Link]
Email: amarhonwad36@[Link] Email: halagunakianil2244@[Link]
Rahul Patil
Department of Electronics and
Communication
Bldea’s V. P. Dr. P. G. Halakatti
College of Engineering
Vijayapura 586103, India
Email: rahulpatil5234@[Link]
Abstract— Numerous studies have utilized machine provides a faster and more accurate alternative. Machine
vision to assess the visual quality of rice. Rice, along with vision eliminates human biases and fatigue, ensuring precise
other food crops like wheat, potatoes, soybeans, and maize, grain classification.
is a staple food consumed by people worldwide, particularly
in Asian countries. Rice is primarily categorized based on its This paper outlines the procedure for determining rice
grain shape, colour, and other characteristics. Grains serve quality percentage and discusses various physical and
as the main source of agricultural income for our nation. chemical attributes involved. Ultimately, the adoption of
However, these grains often contain contaminants such as image processing techniques promises to revolutionize grain
stones, weed seeds, chaff, and damaged seeds. Currently, quality assessment, providing a more efficient and reliable
evaluating grain quality requires low levels of automation method for the agricultural industry.
and a significant human workforce, resulting in increased
costs and testing time. To address this issue, we propose a II. LITERATURE SURVEY
grain classification system that utilizes machine learning and
image processing algorithms to identify different types of A. Advancements in Food Quality Detection:
grains and determine their purity based on parameters such
as size and shape. This system utilizes the Python Food quality detection has evolved significantly with the
programming language and software for all machine vision integration of machine learning and image processing
operations. Grain classification using image processing techniques. Fifteen research papers delve into various
techniques has been widely applied to differentiate rice applications, including deep learning for quality assessment,
varieties based on unique features including shape and fruit ripeness detection, and automated bakery and fish
length, this paper examines the characteristics of rice, inspection systems. Techniques such as convolutional neural
including its chalkiness, colour, and internal damage. networks, support vector machines, transfer learning, and
Additionally, it discusses and proposes methods for decision trees are employed to enhance food safety and
classifying four different rice varieties. Furthermore, the consumer satisfaction.
paper explores the use of image processing techniques to
determine the purity percentage of rice grains by analyzing B. Exploring Diverse Applications:
various features such as grain colour and shape.
These studies also cover disease detection in vegetables,
Keywords—Rice Analysis, Image Processing, Grain Purity contaminant detection, egg quality assessment, and milk
spoilage detection. Through innovative computational
Assessment, Quality Control
methods, they aim to address challenges in ensuring the
integrity and excellence of food products, representing a
I. INTRODUCTION (HEADING 1) significant advancement in the food industry's quality control
The agricultural sector, with its rich history, faces the practices.
ongoing challenge of assessing grain quality. This study
presents an innovative solution for evaluating and grading III. METHODOLOGY
rice grains using image processing techniques.
The system is divided into smaller modules. The modules are
Traditionally, rice grading relies on manual size
as follow Using an image processing method, the evaluation
classification, prone to human error. Integrating image
of the quantity of rice seeds is carried out, followed by
processing offers a non-destructive and cost-effective
categorizing them according to specific factors such as
method, enhancing accuracy and objectivity. Rice quality is
length, width, and the ratio between length and width. More
multifaceted, encompassing physical and chemical attributes.
specifically, the term "length" refers to the average
While conventional methods like dial micrometres are measurement of rice grains in the longitudinal direction,
time-consuming and prone to errors, image processing while "width" pertains to the average measurement in the
XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE
transverse direction. The length-to-width ratio is calculated F. Classification Criteria based on Aspect Ratio:
using the formula L/B = [(Average length of rice a) Aspect Ratio Calculation: The aspect ratio of each
grain)/(average width of rice)]*10. rice grain is calculated using the formula: aspect ratio =
The entire system is divided into smaller modules, which are width/height. If the aspect ratio is less than 1, it is normalized
as follows: to ensure a positive value: aspect ratio =
1/aspect ratio.
A. Image Pre-Processing: b) Slender: If the aspect ratio is greater than or equal to
During the first stage, the image pre-processing process 3, the rice grain is classified as “Slender”.
takes place, wherein a filter is used to remove any noise that c) Medium: If the aspect ratio is between 2.1 and 3
may have been generated during the image acquisition. This (inclusive), the rice grain is classified as “Medium”.
filter not only eliminates noise but also enhances the
sharpness of the image. Additionally, a threshold algorithm is d) Bold: If the aspect ratio is between 1.1 and 2.1
employed to separate the rice grains from the black (inclusive), the rice grain is classified as “Bold”.
background. The filter is specifically applied to eliminate any e) Round: If the aspect ratio is less than or equal to 1,
noise that might occur during the image acquisition, while the rice grain is classified as “Round”.
also improving the overall sharpness of the image. The
f) Output format: The classification result is formatted
utilization of a threshold algorithm facilitates the
as a string enclosed in parentheses, making it easier to
segmentation of the rice grains from the black background.
concatenate with other information. In summary, the
classification is based on the relative proportions of width and
B. Shrinkage Morphological Operation:
height, and each rice grain is categorized into one of the four
To tackle the issue of segmenting rice kernels that are classes: Slender, Medium, Bold or Round. The classification
touching, a shrinkage morphological operation is utilized. provides insights into the shape characteristics of the rice
This procedure starts with erosion, which effectively grains.
separates interconnected characteristics of the rice grains
while ensuring the integrity of each individual grain is
maintained. Erosion is applied to separate the touching
features of the rice grains without compromising the integrity
of any single feature.
C. Edge Detection:
The identification of rice grain boundaries is crucial, and
edge detection plays a significant role in achieving this. To
efficiently detect these edges, the canny algorithm is
employed. In the realm of vision and motion toolbox, there
are six available methods for edge detection, including
differentiation, gradient, permit, Roberts, sigma, and Sobel.
Each method determines the specific type of edge detection
filter to be utilized. In our proposed methodology, we utilized
the Sobel method for edge detection.
D. Object Measurement:
In the fourth stage, the process involves measuring the
objects, specifically determining the number of rice grains.
Once the grains are quantified, algorithms for edge detection
are utilized to obtain endpoint values for each individual
grain. By using a calliper, the endpoints can be connected,
allowing for the measurement of both length and breadth.
These dimensions are then used to calculate the ratio between Figure 1: Architecture Diagram of the proposed model
length and breadth. Through the use of the calliper, we can
join the endpoints and measure the length and breadth values Grain L/B ratio
for each grain, ultimately enabling us to calculate the length- Shape
breadth ratio. Slender Over 3
E. Object Classification: Medium 2.1-3
During the last phase of the algorithm, the task of object
classification takes place. This involves gathering a set of Bold 1.1-2
standards, measured, and calculated results. To summarize,
the systematic utilization of image processing methods, Round 1 or less
which include pre-processing, morphological operations,
edge detection, measurement, and classification, constitutes a
thorough approach for precisely measuring and categorizing Figure 2: Classification Criteria based on Aspect Ratio
rice seeds according to their size and shape characteristics.
IV. SOFTWARE REQUIREMENTS ii) Contour Detection: The processed image is analysed to
detect the outlines of each rice grain, and a function is used
1) The Software requirements are as follows: to determine the number of grains detected. Additionally, the
function iterates through each contour to calculate the aspect
Visual Studio Code: Visual Studio Code, developed by
ratio of each rice grain.
Microsoft, is a lightweight and open-source code editor. It
offers a modern and customizable interface for software a) Rice grain Information: The aspect ratio, classification,
development on various platforms. and average aspect ratio of rice grains are printed, and
Python: Python is utilized as the programming language for information about each grain is stores in a list named “grain
the complete application. It offers a clear and easily info”.
understandable syntax, making it ideal for swift development.
b)Dust percentage: To calculate_dust_percentage function is
Flask: Flask, a Python micro web framework, streamlines the called to determine the percentage of dust in the image.
creation of web applications by offering tools and libraries for
typical web development duties. Within this code, Flask c)Visualization: The processed images are converted to
serves as the central framework that manages HTTP requests base64 strings for display in the browser, while a pie chart is
and responses. generated using Matplotlib represent the dust percentage and
rice grain percentage.
OpenCV(cv2): OpenCV, also known as the Open-Source
Computer Vision Library, is employed for computer vision
purposes. In this particular application, OpenCV is utilized iii)Flask Route (@[Link](“/”)):
for carrying out image processing tasks, which encompass The route handles both GET and POST requests, rendering
operations such as thresholding, filtering, erosion, dilation, the [Link] template with an image upload form for GET
and contour detection. requests, while processing the uploaded image and displaying
NumPy: NumPy is a robust Python library that offers the results on the [Link] template for POST request.
extensive capabilities for performing numerical operations. It
facilitates the handling of large arrays and matrices with iv) HTML Templates:
multiple dimensions, as well as provides a wide range of a) [Link]: A simple HTML form for uploading
mathematical functions. In the given code, NumPy is most images.
likely employed to efficiently manipulate arrays within the
realm of image processing. b) [Link]: Displays processed images, a pie chart, grain
information, average aspect ratio, and set percentage.
a) Matplotlib: Matplotlib is a versatile library that allows
you to create visualizations in Python, whether they are c)Project Report Integration: The interactive elements of the
static, animated, or interactive. The code utilizes web application allow users to submit pictures for in-depth
Matplotlib to produce a pie chart that displays the examination, with a focus on how the classification system
percentages of dust and rice grains. categorizes rice grains. This is enhanced by visual
representations such as pie charts, which effectively illustrate
b)Web Browser: The Flask web application is accessed by the percentage of dust and rice grains. These features provide
end-users through a web browser. HTML templates are a thorough comprehension of the code and its functionality
utilized to create the user interface, and the outcomes are within the project report.
presented within the browser.
2) The implementation steps are as follows: V. EXPERIMENTAL RESULTS
i) Image Processing Functions:
a) Get classification(ratio): The classification process sorts
rice grains according to their aspect ratio, rounding the value
to the nearest tenth and assigning them into categories such
as Slender, Medium, Bold, or Round. The classification is
indicated in parentheses.
b) Calculate_dust_percentage(img): The function computes
the dust percentage in the provided image by applying a
threshold to generate a binary image. It then identifies dust
particles through contours and calculates the dust percentage
as the ratio of dust pixels to the total number of pixels in the
image.
c) Image Filtering and Transformation: The process starts
by converting the input image into binary format using a
threshold. Next, a 5x5 averaging filter is applied to smoothen
the binary image. After that, erosion and dilation operations
are performed to enhance the features of the image. Finally,
the Canny algorithm is used for edge detection.
Figure 3: Results
a) Binary Image: A binary image is a type of digital Both the grouped bar chart and the pie chart play vital
image where each pixel can only have one of two values, roles in conveying important information about the
usually 0 (black) or 255 (white). It is often used for image classification and quality assessment of rice grains.
segmentation or representing objects in a clear and simple
way.
b) Filtered Image: A filtered image results from
applying a filter or convolution operation to the original
image. Filters modify the intensity of pixels based on their
surrounding values.
c) Eroded Image: Erosion is a morphological
operation that expands or thickens objects in a binary image.
It is achieved by moving a structuring element over the image
and replacing each pixel with minimum value in its
neighbourhood.
d) Edge Image: An edge image highlights boundaries
Figure 5: Grouped bar chart of Average Aspect Ratio Vs
or transitions between different regions in an image. It
represents areas of rapid intensity change. However, it Classification
represents the distribution of two categories: “Dust
Percentage” and “Rice Grain”. The chart aims to visually
convert the proportion of these two components in the
processed image.
e) Dust Percentage: This represents the percentage of
the image covered by dust particles. The code uses image
processing techniques to identify and calculate the area
occupied by dust. The dust percentage is then displayed in the
pie chart.
f) Rice Grain Percentage: This represents the
percentage that complements the dust percentage and
signifies the portion that is not covered by dust, but rather
assumed to be occupied by rice grains. The calculation
involves subtracting the dust percentage from 100%. Each
section of the pie chart corresponds to either the "Dust
Percentage" or the "Rice Grain Percentage." The chart is
appropriately labelled, and the percentage values are
indicated on each section. The colours employed in the pie
chart are "light coral" for dust and "lightskyblue" for rice
grains.
Figure 6: Table for Individual Aspect Ratio and it’s Type
Figure 4: Pie-chart of Dust Percentage and Rice Grain VI. CONCLUSION AND FUTURE SCOPE
Percentage
Conclusion:
To simplify the classification process, a bar chart is used Our project focuses on the comprehensive classification of
in this specific scenario to group similar data. This chart rice grain samples and a meticulous analysis of their quality
effectively presents information about the classification based on the aspect ratio. Our approach sets itself apart from
existing works by not only identifying and quantifying rice
of rice grains. It is worth mentioning that the chart
grains, but also evaluating their quality and categorizing them
consists of two separate bars: the blue bar represents the
accordingly. This is particularly important for efficiently
total number of rice grains in the dataset, while the red
grading a large volume of grains. Our methodology
bar represents the average aspect ratio of the rice grains.
significantly speeds up this process, reducing the time and
effort required for manual analysis.
To analyse the grains, we utilize image analysis algorithms REFERENCES
on randomly arranged single-layer images of rice grains. We
employ edge detection to identify boundary regions and [1] Jagdeep Singh Aulakh, Dr. V.K. Banga, “Grading of rice
determine the endpoints of each individual grain. Using a grains by image processing”, International Journal of
calliper, we then measure the length and breadth of each Engineering Research & Technology (IJERT), Vol. 1 Issue
4, June 2012.
grain. These measurements enable us to calculate the length-
breadth ratio, which further aids in assessing the quality of [2] Chetana V. Maheshwari, Kavindra R. Jain, Chintan K.
the grains. Modi, “Non-destructive Quality Analysis of Indian Gujarat-
17 Oryza Sativa SSP Indica (Rice) Using Image
The utilization of these algorithms demonstrates great Processing”, International Journal of Computer Engineering
effectiveness in assessing the quality of grains by considering Science (IJCES), Vol. 2 Issue 3, March 2012.
their dimensions. Our suggested approach offers several key
[3] Bhavesh B. Prajapati, Sachin Patel, “Classification of Indian
benefits, including a faster process, reduced time
Basmati
requirements, cost-effectiveness, and superior performance
Rice Using Digital Image Processing as per Indian Export
when compared to traditional manual techniques.
Rules”, International Research Journal of computer Science
Engineering and Applications, Vol. 2 Issue 1, January 2013.
Future Scope:
[4] S. Kanchana, S. Lakshmi Bharati, M. Ilam ran and K.
In order to conduct a thorough quality analysis, it is Singaravadivel, “Physical Quality of Selected Rice
Verities”, World Journal of Agriculture Sciences, pp. 468-
necessary to utilize image processing techniques to measure
472, 2012.
a wide range of parameters. The next step in this research
could involve developing a system that is capable of [5] Bhupinder Verma, “Image Processing Techniques for
classifying rice grains based on each individual parameter, Grading & Classification of Rice”, International Conference
with the aim of improving the overall quality of the rice. It is on Computer and Communication Technology (ICCCT),
important that such a system is cost-effective and minimizes pp. 220-223, 2012 [6] G. Ajay, M. Suneel, K. Kiran Kumar,
P. Siva Prasad, “Quality
the time required for quality analysis.
Evaluation of Rice Grains Using Morphological Methods”,
International Journal of Soft Computing and Engineering
(IJSCE), pp. 35-37, Vol. 2, Issue 6, January 2013.
ACKNOWLEDGMENT (Heading 5) [7] Harpreet Kaur, Baljit Singh, “Classification & Grading Rice
using
We gratefully thank the Dr. R. M. Math Sir for their
Multi-Class SVM”, International Journal of Scientific and
invaluable guidance and expertise in enhancing the accuracy Research Publications (IJSRP), Vol. 3, Issue 4, April 2013
of rice grain quality analysis.
[8] Shilpa J. Bhonsle, “Grain Quality Evaluation and
Organoleptic Analysis of Aromatic Rice Varieties of Goa,
India”, Journal of Agricultural Science, pp. 99- 107, Vol. 2,
No. 3; September 2010.
[9] ”Laboratory Manual on Rice Grain Quality”, Directorate of
Rice Research, Rajendranagar, Hyderabad, September
2013.