You are on page 1of 7

Z. Grid. Rigra. and Fd. Sc. 60(1)(2008): 183 188 S. S.

Sandhu and Mohd Ghafar




Image processing and analysis for weight mangoes
S. S. Sandhu * and Mohd Ghafar *

Key words: image capture, image filter, image threshold, mango size,
mango weight


Abstract
Size is one of the major parameters that the consumer identifies to be related to
the quality of mango. According to Federal Agricultural Marketing Authority
(FAMA) Malaysia, size of mango is determined by weight. This paper presents
a study on measuring the weight of Chokanan mangoes using image processing
and analysis techniques. The computing PCI software was used to process and
analyse mango image obtained from image acquisition system. Number of pixels
of mango region in the captured image was counted by the software after image
processing and analysing processes. A relationship between mango pixels and
mango weights was analysed using statistical method of regression.the results of the weight
measurement for all 30 mangoes in reference set and the weights ranged from
207 to 438 g. Mean () and standard deviation (s) of the 30 samples data were the process of
converting pixels to grams of objects that will be the greatest distance calculated results and the
smallest distance . the distance is the ratio between the number of pixels the
object, feasible and effective in estimating weight of mangoes.

Introduction
Mango is one of the major fruits produced in
Malaysia with the export value of 126,000 t
in the year 2002. Post-harvest handling
is an important stage in fruit production
process to ensure the fruit quality. The post-
harvest handling process involves cleaning,
grading and packaging. Grading is essential
for determining fruit quality and also for
pricing. Many local producers are still very
much dependent on human labour to grade
the fruits following grade recommended by
Federal Agricultural Marketing Authority
(FAMA) Malaysia. The fruits are graded
based on size, maturity index and external
defects of fruit.
Computer vision systems can be used
for automated fruits inspection and grading.
These systems have been widely used
in the food and agricultural industry for
inspection and evaluation as they provide
suitable rapid, economic, consistent and
objective assessment (Sun 2000). According
to Kanali et al. (1998) the automated

*Mechanization and Automation Research Centre, MARDI Headquarters, Serdang, P.O. Box 12301, 50774
Kuala Lumpur, Malaysia
Authors full names: Teoh Chin Chuang and Mohd Syaifudin Abdul Rahman
E-mail: cchin@mardi.my
Malaysian Agricultural Research and Development Institute 2007

183

Techniques for estimating weight of mangoes

inspection of produce using machine vision
not only results in labour savings, but also
improves inspection objectivity. Over the
past decade, advances in hardware and
software for digital image processing and
analysis have motivated several studies on
the development of the system to evaluate
quality of diverse and processed foods
(Gerrard et al. 1996; Locht et al. 1997).
Image processing and analysis is the
core of computer vision to achieve the
required classification and measurement
(Krutz et al. 2000). Nagata et al. (1997)
investigated the use of image processing and
analysis to sort fresh strawberries based on
size and shape. The results showed that the
system was able to sort 600 strawberries
into three grades of shape and five grades of
size with an accuracy of 9498%.
Toa et al. (1995) performed a study
to classify Golden Delicious apples into
yellow and green groups using the HIS
(hue, intensity, saturation) colour system
method. The results showed that an
accuracy of over 90% was achieved for the
120 samples tested.
A study by Kondo (1995) on the
quality through correlation of the appearance
with sweetness of Iyokan oranges using
image analysis demonstrated that the method
effectively predicted the sweetness of the
oranges with 87% correlation efficiency
between measured and calculated sugar
content. Leemans et al. (1998) investigated
the surface defect detection of Golden
Delicious apples using image analysis.
The results showed that the image analysis
effectively detected various defects such as
bruises, russet, scads, fungi or wounds.
Sizes of tomato, potato, raisin and
apple have been estimated in different
ways using image processing and analysis
techniques in the studies by Sarkar and
Wolfe (1985), Toa et al. (1990), Okamura
et al. (1991) and Varghese et al. (1991),
respectively.
Size is one of the major parameters that
consumer identifies together with the quality
of fruits (Aleixos et al. 2002). According

184


to FAMA, size of tropical fruits (i.e.
mango, pineapple, watermelon, papaya and
starfruit) is determined by weight. Manual
weighing of fruits for grading size is time
consuming, labour intensive, and costly.
Image processing and analysis techniques in
the computer vision system can be used as
an alternative automated grading of fruit size
based on weight.
The objective of this paper was
to determine how correctly the image
processing and analysis measured the
weight of the Chokanan mangoes, as well
as estimating the error, in order to evaluate
the ability of the linear model developed in
the linear regression analysis for estimating
weight of the mangoes.

Materials and methods
Sampling
A total of 100 random samples of
physiologically mature and green condition
of Chokanan mangoes were harvested from
an orchard at Rembau, Negeri Sembilan.
Fruits were weighed using the digital
balance. The samples were separated into
reference and evaluate sets of 50 samples
each. The 50 mango samples from reference
set were used to develop a linear regression
model for weight estimation. While the other
50 mangoes from evaluate set were used to
verify the model.

Image capturing
The 100 mango samples were immersed
in water and cleaned using a soft sponge.
Following that the fruits were exposed to
an image acquisition system (Figure 1)
consisted of a colour camera, a computer
equipped with an image acquisition board,
and a lighting system for capturing mango
images. The images were captured in a room
with a proper control environment such as
lighting and height (22 cm) from camera
to mango. The resolution of each captured
image was 0.3 mm/pixel.
N
u
m
b
e
r
o
f
p
i
x
e
l
s

Light

source
Light source
Mango




Digital camera


Computer





22 cm



Black background

Image processing and analysis
Image processing and analysis were
performed by filtering and thresholding
processes with using PCI software. Image
filtering is an enhancement operation that
alters pixel values on the basic of the grey
values of its surrounding neighbours to
correct problems such as poor contrast or
noise.
A 15 x 15 window median filter was
selected out of many different filters that
can be used to correct inconsistencies in
the acquired images that were caused by
inadequate and non-uniform illumination.
This filter is a simple sliding-window spatial
filter that replaces the centre value of the
window with average (mean) of all the pixel
values. A filter window is defined by its
dimensions of an odd number of pixels and
lines. Each pixel of the window contains a
coefficient or weighting factor representative
of some mathematical relationship.
A filtered image is generated by
multiplying each coefficient in the window
by the grey level in the original image
corresponding to the windows current
location and assigning the result to the
central pixel location of the window in the
filtered channel. The window is moved
throughout the image one pixel at a time.
A total of 100 filtered images were generated
by the 15 x 15 window median filter.
Image thresholding was used to
discriminate mango object from the
background of filtered mango image. An
Figure 1. Image acquisition
system



Background


Object

Grey level values




T
Figure 2. Bimodal histogram

analysis of shape of an image histogram
can be used to threshold the filtered mango
image. The image histogram is created by
plotting the number of pixels, which have a
specific grey level value, versus that value.
Figure 2 shows the image histogram
with two peaks and a valley, indicated by
threshold (T) between them, such an image
histogram usually called bimodal histogram.
Image histograms for all 100 filtered mango
images were bimodal histogram in this
study, as a result it is possible to use a
simple thresholding algorithm to segment
the filtered mango image into mango object
and background regions. The thresholding
algorithm is shown below:




185
{

Techniques for estimating weight of mangoes

g(x,y) =
0, if f(x,y) T
1, otherwise
Table 1. Mango pixels and actual weight of
mangoes in reference set
Samples Counted mango Actual weight
where g(x, y) is the image after thresholding,
f(x, y) is the original filtered mango image
and T is the threshold. All pixels of filtered
mango image with grey level values greater
than T were classified as object pixels (1),
while pixels with grey level values equal or
smaller than T were labelled as background
pixels (0). The number of pixels of mango
region in thresholded image was counted for
regression analysis with the mango weight.

Statistical analysis
A linear regression analysis was used to
analyse the relationship between mango
2-dimension (2D) area of thresholded
image and mango weight. The 2D area
is determined by the number of mango
region pixels in the thresholded image. In
the regression analysis, a linear model was
developed to predict the weight (dependent
variable) of mango from the counted mango
pixels (independent variable). To evaluate
the linear model, a 95% confidence and
prediction intervals graph was used to prove
the linear model adequately fits the data.
.

Results and discussion
Table 1 shows the results of the weight
measurement for all 30 mangoes in
reference set and the weights ranged from
207 to 438 g. Mean () and standard
deviation (s) of the 30 samples data were the
process of converting pixels to grams of objects
that will be the greatest distance calculated results
and the smallest distance . the distance is the ratio
between the number of pixels the object with
reference number of pixels a grams by the
following equations.

Pixel a grams = the number of pixels the object
Original Size (grams)


186
pixels (g)
1 92315 307
2 83307 277
3 81981 273
4 79892 266
5 84491 281
6 72187 240
7 87059 290
8 76294 254
9 62217 207
10 94051 313
11 76062 253
12 88747 295
13 87150 290
14 84321 281
15 75716 252
16 89577 298
17 85453 284
18 104406 348
19 97576 325
20 111259 370
21 104682 348
22 99997 333
23 110139 367
24 105988 353
25 112144 373
26 122092 406
27 106380 354
28 120230 400
29 109798 365
30 131609 438

Pixel a grams =
g pixels
g
/ 300
438
pixels 131609


Pixel a grams =
g pixels
g
/ 300
207
pixels 62217


In the resultant object reference length is 131609
pixels for a large number of pixels and 62217 pixels
for a small number of pixels. In the original
measurement of the size of a large mango fruit weight
is 438 grams and the small size of the original
measurement mango fruit is 207 grams. so the
reference pixels per gram is as follows.



W
e
i
g
h
t
(
g
)

S
t
a
n
d
a
r
d
i
z
e
d
r
e
s
i
d
u
a
l
s

Techniques for estimating weight of mangoes

400
350
300
250
200
150
Data
Linear fit of the data
Prediction bands
Confidence bands



Figure 3. Mango image captured by digital
camera









Figure 4. Filtered image
100
60000 80000 100000 120000 140000
Pixels
Figure 6. The dependency between counted pixels
and weight
2
1.5
1
0.5
0
-0.5
-1

-1.5











Figure 5. Thresholded image
does not show any pattern. This gave
confidence regarding the normal distribution
of the data. As a result, it suggests that
assumptions are fulfilled.
The plot also can be used to observe
the outliers or erroneous problem. The
result from the plot showed that there are
no extremely large residuals (and hence no
apparent outliers) and that there is no trend
in the residuals to indicate the linear model
is inappropriate.


187
-2

60000 80000 100000 120000 140000
Pixels
Figure 7. The residuals (error) distribution

The verification results of the
developed linear model by using 30 mangoes
of evaluate set are given in Table The
a mango weight using In the resultant object
reference length is 131609 pixels for a large number
of pixels and 62217 pixels for a small number of
pixels. In the original measurement of the size of a
large mango fruit weight is 438 grams and the small
size of the original measurement mango fruit is 207
grams.Thus, weight of mango can be
estimated with a high degree of accuracy by
image processing and analysis techniques.

Conclusion
Measurements of the weight of Chokanan
mangoes can be accomplished using the
image processing and analysis techniques.
The results showed that image filtering
and image thresholding are providing a
simple and effective means smoothing and
segmenting the mango image. Mango pixels



Table 1 shows the results of the weight
measurement for all 30 mangoes in
reference set and the weights ranged from
207 to 438 g. Mean () and standard
deviation (s) of the 30 samples data were the process
of converting pixels to grams of objects that will be
the greatest distance calculated results and the
smallest distance . the distance is the ratio between
the number of pixels the object with reference
number of pixels a grams by the following equations.

The present work has achieved the
first phase of using image processing and
analysis technique to determine weight of
Chokanan mangoes. It is recommended that
further research to develop a machine vision
system that utilizes the above developed
linear model for grading size of mangoes
automatically be given emphasis.

References
Aleixos, N., Blasco, J., Navarrn, F. and Molt,
E. (2002). Multispectral inspection of citrus
in real-time using machine vision and
digital signal. Computers and electronics in
agriculture 33: 1317
Gerrard, D.E., Goa, X. and Tan, J. (1996). Beef
marbling and colour score determination by
image processing. Journal of Food Science
61: 1458
Kanali, C., Murase, H. and Honami, N. (1998).
Three-dimensional shape recognition using a
charge-simulation method to process features.
Journal of Agricultural Engineering Research
70: 195208
Kondo, N. (1995). Quality evaluation of orange
fruit using neural network. Food Processing
Automation IV Proceedinds of the FPAC
conference. Michigan: ASAE
Krutz, G.W., Gibson, H.G., Cassens, D.L. and
Zhang, M. (2000). Colour vision in forest and
wood engineering. Landwards 55: 29
Leemans, V., Magein, H. and Destain, M.F. (1998).
Defects segmentation on Golden Delicious
apples by using colour machine vision.
Computers and Electronics in Agriculture 20:
11730

Locht, P., Thomsen, K. and Mikkelsen, P. (1997).
Full color image analysis as a tool for quality
control and process development in the
food industry. (ASAE. Paper No. 973006).
Michigan: ASAE
Nagata, M., Cao, Q., Bato, P.M., Shrestha, B.P.
and Kinoshita, O. (1997). Basic study on
strawberry sorting system in Japan. (ASAE
Annual International Meeting Technical
Papers. Paper No. 973095). Michigan: ASAE
Okamura, N.K., Delwiche, M.J. and Thompson, J.F.
(1991). Raisin grading by machine vision.
(ASAE Paper No. 917011). Michigan:
ASAE
Sarkar, N. and Wolfe, R.R. (1985). Feature
extraction techniques for sorting tomatoes by
computer vision. Transactions of the ASAE
28: 9704
Sun, D.W. (2000). Inspection pizza topping
percentage and distribution by a computer
vision method. Journal of Food Engineering
44: 2459
Toa, Y., Heinemann, P.H., Varghese, Z., Morrow,
C.T. and Sommer, H.J. (1995). Machine
vision for colour inspection of patotoes and
apples. Transactions of the ASAE 38(3):
155561
Toa, Y., Morrow, C.T., Heinemann, P.H. and
Sommer, J.H. (1990). Automated machine
vision inspection of potatoes. (ASAE Paper
No. 903531). Michigan: ASAE
Varghese, Z., Morrow, C.T., Heinemann, P.H.,
Sommer, J.H., Tao, Y. and Crasswell, R.M.
(1991). Automated inspection of Golden
Delicious apples using colour computer
vision. (ASAE Paper No. 917002).
Michigan: ASAE







188

You might also like