You are on page 1of 17

Rice Quality Analysis Using Image

Processing

Submitted for third review as part of J component in Image processing

By

Group 14

1. Karri Radheer Reddy - 17BCE0381


2. Jaimin Shah - 14BCE0093
3. Gowrab Bhowmick - 14BCE0875
4. Pranshu Tripathi - 17BCE0761

SCHOOL OF COMPUTER SCIENCE ENGINEERING

November 2017
ACKNOWLEDGEMENT

We would like to thank our guide, Dr. V. Santhi for the time, support and
knowledge she has granted us. We would like to thank the school of SCOPE and the
VIT university as a whole. Last but not the least we would like to thank all those who
have helped us actively or passively in our work, this project would not have been
possible without their guidance. we are highly grateful to VIT University for
providing a platform to achieve academic success. we would also like to express my
gratitude to our loved ones who have supported us throughout the whole process.

2
TABLE OF CONTENTS
1. Introduction
1.1. Theoretical Background
1.2. Motivation
1.3. Aim of the proposed Work
1.4. Objective(s) of the proposed work
1.5. Report Organization
2. Literature Survey
2.1. Survey of the Existing Models/Work
2.2. Summary/Gaps identified in the Survey
3. Overview of the Proposed System
3.1. Introduction
3.2. Framework, Architecture or Module for the Proposed System
3.3. Proposed System Model
4. Proposed System Analysis and Design
4.1. Introduction
4.2. Requirement Analysis
4.2.1. System Requirements
4.2.1.1. H/W Requirements(details about Application Specific
Hardware)
4.2.1.2. S/W Requirements(details about Application Specific
Software)
5. Results and Discussion
5.1. Summary of the Result
6. Conclusion, Limitations and Scope for future Work

3
ABSTRACT

In this project, we take processing, enhancement and analysis of digital images as a


way to determine the quality of different rice samples. Image is processed in Spatial
domain. Image reduction, image enhancement, image increment, object recognition in
spatial domain is applied on grain by grain of different samples of rice to determine
its size, colour and quality as whole to grade the grain of rice.

Keywords - Grading, Rice grain, Quality, Image processing.

4
1. Introduction

1.1 THEORETICAL BACK GROUND

The Agricultural industry on the whole is very vast and ancient. Quality assessment of
grains is a very big challenge since time immemorial. The project presents a solution
for quality evaluation and grading of rice grains using image processing techniques.
Commercially the grading of rice is done according to the size of the grain (full, half
or broken). The food grains quality are rapidly assessed through visual inspection by
human inspectors. The decision making capabilities of human-inspectors are
subjected to external influences such as fatigue, vengeance, bias etc. With the help of
image processing techniques we can overcome that and which are also a
nondestructive and cost-effective techniques. Here we also discuss the procedure used
to obtain the percentage quality of rice grains. Rice quality is nothing but the
combination of physical and chemical characteristics. Grain size and shape,
chalkiness, whiteness, milling degree, bulk density and moisture content are some
physical characteristics , gelatinization temperature and gel consistency are chemical
characteristics of rice.

1.2 MOTIVATION
The paper presents a solution of grading and evaluation of rice grains on the basis of
grain size and shape using image processing techniques. Specifically edge detection
algorithm is used to find out the region of boundaries of each grain. In this technique
we find the endpoints of each grain and after using caliper we can measure the length
and breadth of rice. This method requires minimum time and it is low in cost.

1.3 AIM OF PROPOSED WORK


In this study, the image processing algorithms are developed to segment and identify
rice grains. Use of image processing algorithm is an efficient method to analyze
grains quality by its size.

1.4 OBJECTIVE OF PROPOSED WORK


To analysis and classify the quality of rice grains.

5
2. LITERATURE REVIEW

1. Gurpreet Kaur & Bhupinder Verma have proposed computer vision techniques for
grading of rice kernels based on their sizes (full, medium, half). The images are
acquired using a digital camera having high pixel resolution.
2. Jagdeep Singh Aulakh& V.K. Banga proposed image processing techniques for
grading of rice samples based on their sizes . The images were captured using a Flat
Bed Scanner (FBS).
3. Chetna V. Maheshwari et al., proposed image processing techniques for identifying
two varieties of rice based on their shape and size. Image of a sample spread on the
black or butter paper were captured using a digital Camera. The edge detection
operation was performed to calculate the Geometric parameters.
4. Kasun Herath proposed the use of a machine vision system for grain classification.
It is based on special features such as shape,length,chalkiness,colour and internal
damage of rice,RCB colour model,histogram,edge detection etc.
5. Deepika Sharma & Sharad D.Sawant proposed a system that determines the quality
of food by running the grain samples on the conveyor belt and then random images of
grains are captured by the camera. MATLAB is used and classification is done based
on colou,shape and size. It finally results in good,bad and medium quality by using
Neural Network(NN) classifier.

2.2 SUMMARY
We have reviewed and tried to implement the above papers. We have here presented a
hybrid approach where a part of implementations of the above are taken into
consideration, giving us a more accurate measure and quality of the rice grains.

6
3 OVERVIEW OF THE PROPOSED SYSTEM

3.1 INTRODUCTION

The image processing technique is used for counting the number of rice seeds and
classifies them on the basis of length, breadth and length - breadth ratio. Length is the
average length of rice grain while breadth is the average breadth of rice grain and
length-breadth ratio is calculated as:
L/B=[(Average length of rice grain)/(average breadth of rice)]*100
In first pre-processing step image registration takes place and noise is removed from
the image by using filter. Shrinkage algorithm used for segmenting the touching
kernels which is second step. In third step we perform edge detection to find out the
region of boundaries. In fourth step rice seed measurement is done and in the same
step length, breadth and length-breadth is also measured. In the fifth step of the
algorithm rice is classified according to its size and shape.

3.2 FRAMEWORK

7
3.3 SYSTEM MODEL ANALYSIS
A. Image pre-processing
Filter is applied to remove noise which occurs during the acquisition of image. Filter
also sharpens the image. Threshold algorithm is used to segment the rice grains from
the black background.
B. Shrinkage morphological operation
Erosion is applied to separate the touching features of rice grains without losing the
integrity of single feature. Dilation process follows erosion process. The goal of
dilation is grow the eroded features to their original shape without rejoining the
separated features.
C. Edge detection
Edge detection helps to find out the region of boundaries of rice grains. We use canny
algorithm to detect the edges.
D. Object measurement
Measurement indicates the count of rice grains. After getting the count of rice grains,
edge detection algorithms applied on the image and outcome of the applied algorithm
is we get endpoint values of each grain. We use caliper to join the endpoints and
measure the value of length and breadth of each grain. After getting the value of
length and breadth we can calculate length-breadth ratio.
E. Object classification
Classification requires all standard, measured and calculated results. The standard
database for rice size and shape measurement is referred from laboratory manual on
rice grain quality, Directorate of Rice Research, Rajendranagar, Hyderabad. The
classification of rice grains as per the standard database is shown in following tables.
Table below indicates classification of rice grains on the basis of length and length-
breadth ratio:
Long Slender (LS) Length >= 6mm, L/B Ratio>=3mm

Short Slender (SS) Length< 6mm, L/B Ratio>=3mm

Medium Slender (MS) Length >= 6mm, 2.5 <L/B Ratio<3mm

Long Bold (LB) Length >= 6mm, L/B Ratio<3mm

Short Bold (SB) Length < 6mm, L/B Ratio<3mm

8
4 REQUIREMENTS
4.1 SYSTEM REQUIREMENTS
4.1.1 H/W REQUIREMENTS

OS Name Microsoft Windows 10 Pro


Version 10.0.17134 Build 17134
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name DESKTOP-9O2NGJT
System Manufacturer HP
System Model HP Notebook
System Type x64-based PC
System SKU 1HQ16PA#ACJ
Processor Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz, 2401 Mhz, 2
Core(s), 4 Logical Processor(s)
BIOS Version/Date Insyde F.24, 05-01-2017
SMBIOS Version 2.8
Embedded Controller Version 61.41
BIOS Mode Legacy
BaseBoard Manufacturer HP
BaseBoard Model Not Available
BaseBoard Name Base Board
Platform Role Mobile
Secure Boot State Unsupported
PCR7 Configuration Binding Not Possible
Windows Directory C:\Windows
System Directory C:\Windows\system32
Boot Device\Device\HarddiskVolume1
Locale United States

9
Hardware Abstraction Layer Version = "10.0.17134.285"
User Name DESKTOP-9O2NGJT\Intel
Time Zone India Standard Time
Installed Physical Memory (RAM) 4.00 GB
Total Physical Memory 3.89 GB
Available Physical Memory 0.99 GB
Total Virtual Memory 6.72 GB
Available Virtual Memory 2.05 GB
Page File Space 2.83 GB
Page File C:\pagefile.sys
Kernel DMA Protection Off
Virtualization-based security Not enabled
Device Encryption Support Reasons for failed automatic device
encryption: TPM is not usable, PCR7 binding is not supported, Hardware
Security Test Interface failed and device is not InstantGo, TPM is not
usable
Hyper-V - VM Monitor Mode Extensions Yes
Hyper-V - Second Level Address Translation Extensions Yes
Hyper-V - Virtualization Enabled in Firmware No
Hyper-V - Data Execution Protection Yes

4.1.2 S/W REQUIREMENTS

IDLE ( Python 3.7.1 )

10
5. RESULTS AND DISCUSSION

5.1 SUMMARY OF THE RESULT

Accuracy of counting total number of grains in the images should be 100% and it
should be suitable to grade large quality of grains efficiently, which otherwise will
consume lot of time in manual analysis, this feature will be able to save lot of time &
human effort.

5.1.1 TEST IMAGES

11
5.1.2 CODE

import cv2
import numpy as np
from matplotlib
import pyplot as plt

def get_classificaton(ratio):
ratio =round(ratio,1)
toret=""
if(ratio>=3):
toret="Slender"
elif(ratio>=2.1 and ratio<3):
toret="Medium"
elif(ratio>=1.1 and ratio<2.1):
toret="Bold"
elif(ratio<=1):
toret="Round"
toret="("+toret+")"
return toret
#rnjn
print("Starting")
img = cv2.imread('rice.png',0)#load in greyscale mode

#convert into binary


ret,binary = cv2.threshold(img,160,255,cv2.THRESH_BINARY)# 160 - threshold,
255 - value to assign, THRESH_BINARY_INV - Inverse binary

#averaging filter
kernel = np.ones((5,5),np.float32)/9
dst = cv2.filter2D(binary,-1,kernel)# -1 : depth of the destination image

12
kernel2 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3))

#erosion
erosion = cv2.erode(dst,kernel2,iterations = 1)

#dilation
dilation = cv2.dilate(erosion,kernel2,iterations = 1)

#edge detection
edges = cv2.Canny(dilation,100,200)

### Size detection


_,contours,hierarchy = cv2.findContours(erosion, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
print ("No. of rice grains=",len(contours))
total_ar=0
for cnt in contours:
x,y,w,h = cv2.boundingRect(cnt)
aspect_ratio = float(w)/h
if(aspect_ratio<1):
aspect_ratio=1/aspect_ratio
print (round(aspect_ratio,2),get_classificaton(aspect_ratio))
total_ar+=aspect_ratio
avg_ar=total_ar/len(contours)
print ("Average Aspect Ratio=",round(avg_ar,2),get_classificaton(avg_ar))
#plot the images
imgs_row=2
imgs_col=3
plt.subplot(imgs_row,imgs_col,1),plt.imshow(img,'gray')
plt.title("Original image")

plt.subplot(imgs_row,imgs_col,2),plt.imshow(binary,'gray')
plt.title("Binary image")

13
plt.subplot(imgs_row,imgs_col,3),plt.imshow(dst,'gray')
plt.title("Filtered image")

plt.subplot(imgs_row,imgs_col,4),plt.imshow(erosion,'gray')
plt.title("Eroded image")

plt.subplot(imgs_row,imgs_col,5),plt.imshow(dilation,'gray')
plt.title("Dialated image")

plt.subplot(imgs_row,imgs_col,6),plt.imshow(edges,'gray')
plt.title("Edge detect")

plt.show()

5.1.3 OUTPUT

14
15
6. CONCLUSION

The image analysis algorithms are applied on image in which rice grains are randomly
placed and spread in one layer. If the error occurs like touching kernels shrinkage
operation works efficiently for separating the connecting part from point touching
kernels. Edge detection is performed to find out the region of boundaries and
endpoints of each grain; and then after that using caliper length and breadth can be
measured. After getting the values for length and breadth, length-breadth ratio is to be
calculated.
In this study, the image processing algorithms are developed to segment and identify
rice grains. use of image processing algorithm is an efficient method to analyze grains
quality by its size. The main benefit of proposed method is it requires minimum time;
cost is less and gives better results compared with manual results or traditional
methods. We have successfully executed all the steps proposed. Last two steps
include calculating the size of the grains and then classifying them according to the
Table provided.

16
7 REFERENCES

[1] Gurpreet Kaur, Bhupinder Verma. “Measurement standards based grading of rice
kernels by separating touching kernels for embedded imaging applications”.
International Journal of Electronics, Communication&Instrumentation Engineering
Research and Development (IJECIERD) Vol. 3, Issue 1,127-134 Mar-2013.
[2] Jagdeep Singh Aulakh, V.K. Banga. “Grading of rice grains by image
processing”, International Journal of Engineering Research & Technology (IJERT)
Vol. 1 Issue 4, June – 2012.
[3] Chetna V. Maheshwari, Kavindra R. Jain, Chintan K. Modi. “Non-destructive
Quality Analysis of Indian Basmati Oryza Sativa SSP Indica (Rice) Using Image
Processing”. IEEE – 2012
[4]Kasun Herath proposed the use of a machine vision system for grain classification.
It is based on special features such as shape,length,chalkiness,colour and internal
damage of rice,RCB colour model,histogram,edge detection etc.
[5]Deepika Sharma & Sharad D.Sawant proposed a system that determines the quality
of food by running the grain samples on the conveyor belt and then random images of
grains are captured by the camera. MATLAB is used and classification is done based
on colou,shape and size. It finally results in good,bad and medium quality by using
Neural Network(NN) classifier.

17

You might also like