# Design and Implementation of Rapid Grading Platform for Shape and Diameter of Oranges Based on Visual C#.NET

Wenshen Jia, Wenfu Wu, Fang Li, Ligang Pan, Zhihong Ma, Miao Gao, Jihua Wang

<figure><img src="image_1.png" /></figure>

To cite this version:

Wenshen Jia, Wenfu Wu, Fang Li, Ligang Pan, Zhihong Ma, et al.. Design and Implementation of Rapid Grading Platform for Shape and Diameter of Oranges Based on Visual C#.NET. 6th Computer and Computing Technologies in Agriculture (CCTA), Oct 2012, Zhangjiajie, China. pp.384-389, 10.1007/978-3-642-36124-1_46 . hal-01348122

HAL Id: hal-01348122

https://inria.hal.science/hal-01348122

Submitted on 22 Jul 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Design and Implementation of Rapid Grading Platform for
Shape and Diameter of Oranges Based on Visual C#.NET¹

Wenshen Jia¹, Wenfu Wu¹, Fang Li¹, Ligang Pan²,³, Zhihong Ma²,³, Miao Gao²,³,
Jihua Wang²,³*

¹School of Biological and Agricultural Engineering, Jilin University, Changchun 130022;

²Beijing Research Center for Agrifood Testing and Farmland monitoring, Beijing 100097, China;

³National Engineering Research Center for Information Technology in Agriculture, Beijing
100097, China;
jiaws09@mails.jlu.edu.cn

**Abstract.** Research on digital image processing technology, which began in 1960s, stepped into an active research stage in late 1970s and early 1980s. It was firstly used in industrial and biomedical fields. Although it put into use in agricultural research very late, it has a broad prospect. In order to realize navel orange grading, this paper used Visual C # .NET program to develop navel orange shape and diameter rapid grading based on machine vision image feature. Southern Jiangxi navel orange was used as the research object. The color and shape feature of the navel orange was extracted. The image data was processed through Sobel Operator algorithm and standard median filter. Results show that the digital image processing technology based on C # program is feasible for shape grading of navel orange. It also provides a new method for navel orange grading detection.

**Keywords:** Visual C#, navel orange, agricultural products, image processing, shape

0 Introduction

Machine vision technology is a computer image processing technology. It is
simulate the human visual system to extract information from the image of
objective things. Processing of such information achieves detection,

¹This work is supported by Research and Demonstration of Authenticity Identification and Quality Safety Traceability Technology of Agricultural Products(201203046) funded by Special Fund for Agro-scientific Research in the Public Interest as well as the Restoration Technology Integration and Demonstration on Disaster destroyed and Wastewater Irrigated farmland (2011BAD04B04) funded by the National Key Technology R&D Program.
measurement and control for the target. The use of machine vision technology for agricultural grading and detection means to use custom-built computer software computing processing of agricultural products image and effective decomposition of the image information. Through the machine vision, the agricultural products of pixel, boundary, shape and so on, has obtained its own characteristics, with a certain pattern to match the image. Finally get to determine the agricultural products quality [1].

Navel orange is one of the largest fruits of our production. At the same time, it is also an important trade fruit. Because of the detection and the grading technology is backward, causing the listed level of navel orange mixed, which affect its commodity value and in particularly cause the lack of competitiveness in the international market. At present, the navel orange grading relies on manual completed in Chinese. The grading results are less consistently and less efficient due to individual diversity of workers. Using machine vision to classify navel orange, which is objectivity strong, stable standard, consistency, high efficiency, and lossless. It is one of the effective ways to solve the artificial grading problem, and machine vision technology is also a hot research topic in agricultural applications [2].

Dimension is one of the main quality parameters in navel orange, also one of the important bases for grading. The sales clerks usually sell navel orange with the dimension grading. Depending on machine vision technology we can obtain the navel orange image, and select the relevant parameters. We can obtain data like volume, weight, diameter of the navel orange and so on.

We develop a grading of software for the navel orange based on machine vision technology. And in accordance with the CAC standards, using diameter of navel orange, we can grade the navel orange.

# 1 Test materials

Test specimen: Navel orange

Producing area: Southern Jiangxi, purchased yuanfang supermarket in Changchun

# 2 System Design

## 2.1 Hardware Architecture

Computer: Hasee Core i3 380M, Memory 6G, Operating System Win7 Ultimate
Light box size: 500 mm×500 mm×400 mm, white background

Light: PAK T5, tricolor circular fluorescent lamp, Power 40W, Color Temperature 6500K, placed on the light box at the top of the central

Camera: Logitech C270, 300 million pixels, the camera installed in the center of the light, Mounting Height: 380 mm from the lens to light box bottom.

## 2.2 Software Design

The system use C # language development, a new programming language, which originate from .NET[3]. C # language evolve from C and C++, that is a Simple, modern, type-safe and object-oriented language. C # is designed for a wide range of enterprise applications running on the .NET platform. .NET Framework includes the common language runtime (CLR) and .NET Framework Class Library (FCL). FCL provides trusteeship applications, and writes object-oriented API[4]. When we write .NET Framework applications, we do not consider to the Windows API, MFC, ATL, COM or other tools and technologies. .NET provides great convenience to programmer, so they only focus on the algorithm in the program is enough. Relative to C and C++ program development, writing the same piece of code, C # is not only the development cycle is short, a small amount of code, and readability. C # requires a lower level of the programmer, and the entry time is shorter. So that the programmer only focus on the algorithm of the digital image, that is greatly improving the efficiency of software development, is very conducive to the application of image processing.

# 3 Image Acquisition & Pretreatment

## 3.1 Image Acquisition

Image acquisition for navel orange use light box which have circular fluorescent lamp and white background. The circular fluorescent lamp first preheats 5 minutes, to ensure the stability of light. Each navel orange collects one picture, and collected a total of 10 pictures.

## 3.2 Image Pretreatment

In order to facilitate detection and extraction of image features for navel oranges, the original image using Photoshop CS5 software batch program for unified clipping zoom 512 x 512 pixels image.
# 4 Image Processing

## 4.1 Navel orange shape extraction

The detection of edge is often uses the airspace differential operator. It is completed through templates and image convolution. There is always a gray edge between two adjacent areas of different gray values. Gray edge is caused by mutation of gray values. The discontinuous of gray values can be easily detected by seeking first-order and second-order derivative of gray values. Existing local edge detection methods include first-order derivative(Sobel Operator, Roberts Operator), second-order derivative(Laplace Operator), template operations(Prewitt Operator, Kirsch Operator, Robinson Operator) and so on[5]. This program use Sobel Operator algorithm.

Sobel Operator weight discrete data and it is use small convolution template (Fig 1). It use convolution of template and corresponding image data as the similar results. The two direction templates are horizontal direction edge detection and vertical edge detection, respectively.

<table><caption>( a ) Vertical gradient direction to detect
the horizontal edge</caption><tr><td>1</td><td>2</td><td>1</td></tr><tr><td>0</td><td>0</td><td>0</td></tr><tr><td>-1</td><td>-2</td><td>-1</td></tr></table>

<table><caption>( b ) Horizontal gradient direction to detect
the vertical edge</caption><tr><td>1</td><td>2</td><td>1</td></tr><tr><td>0</td><td>0</td><td>0</td></tr><tr><td>-1</td><td>-2</td><td>-1</td></tr></table>

<caption>**Fig. 1.** Sobel operator convolution template</caption>

In the image processing the steps of using Sobel operator to detect image edges are as follows[6]:

1) Respectively, both directions template along the image move from one pixel to another pixel, and the center pixel of the template coincide with a location in the image.

2) The coefficients within the template and its corresponding image pixel by multiplying.

3) Get the sum of all the multiplied values.

4) Assign the maximum of the two convolutions to the pixel value of the corresponding template center location, as the pixel of gray value.

Fig 2 (b) by the navel orange original image in Fig 2 (a), calculated after Sobel Operator method.

Fig 2 (c) median filtering images by edge detection image in Fig 2 (b), calculated after median filtering algorithm.

Standard median filter[7] (SMF), which mainly depend on the quick sort
algorithm and is a nonlinear filtering method with less blurred edges, not only remove or reduce the random noise and pulse interference, but also retain edge information. After median filtering navel orange shape is clearly visible, it provides a basis for the further identification of the navel orange appearance grade.

<figure><img src="image_3.png" /><figcaption>Fig. 2. Median filtered image</figcaption></figure>

## 4.2 Navel orange diameter converted

Any color can be expressed by the tristimulus values. The three kinds of stimuli are called as three kinds of primary colors, usually refers to red, green and blue.[8][9]. In 1931 the CIE-RGB color system selects the red (R) for the 700 nm, green (G) for the 546.1 nm, blue (B) for the 435.8 nm. Navel orange generally was orange so the blue component sensitive, which blue pixel value, is less than 220 after the test images judged to be the navel orange part. The effect is very good.

As shown in Fig 2 (d), the difference between navel orange and circular is only 1120 pixels, the different area of navel orange and circular is only 1.4% of the total area. Therefore, it is feasible to derive the diameter of navel orange from circle formula.
The camera lens is 380 mm away from the bottom of the light box. As the lens away from the sample is fixed height, therefore, as long as the statistical proportion of navel orange pixels share of the whole image can be converted navel orange cross-sectional area. In accordance with the largest cross-sectional area of the navel orange, its diameter could be calculated through area formula of a circle. Table 1 shows the level of navel orange graded by diameter in accordance with the CAC standard[10].

<table><caption>**Table 1.** CAC Navel orange grading standards</caption><thead><tr><td>Level</td><td>Diameter (mm)</td></tr></thead><tbody><tr><td>0</td><td>92 - 110</td></tr><tr><td>1</td><td>87 - 100</td></tr><tr><td>2</td><td>84 - 96</td></tr><tr><td>3</td><td>81 - 92</td></tr><tr><td>4</td><td>77 - 88</td></tr><tr><td>5</td><td>73 - 84</td></tr><tr><td>6</td><td>70 - 80</td></tr><tr><td>7</td><td>67 - 76</td></tr><tr><td>8</td><td>64 - 73</td></tr><tr><td>9</td><td>62 - 70</td></tr><tr><td>10</td><td>60 - 68</td></tr><tr><td>11</td><td>58 - 66</td></tr><tr><td>12</td><td>56 - 63</td></tr><tr><td>13</td><td>53 - 60</td></tr></tbody></table>

## 5 Conclusions

This paper studied on navel orange grading detection based on machine vision technologies, and established a navel orange image acquisition system. Through the navel image analysis and processing, this paper realizes the accurately distinguish between navel orange and the background based on Sobel Operator algorithm and standard median filter. Through the detection of the blue band of the image, this method can quickly distinguish between navel orange and the background, and convert the diameter of the navel orange. This method improves the efficiency of image processing, and is of great significance for online rapid detection. The results show that the detection using machine vision technology based on C# program for navel oranges' shape grading is feasible and provide a new idea for the grading detection of navel orange.
Acknowledgment

This work is supported by Research and Demonstration of Authenticity
Identification and Quality Safety Traceability Technology of Agricultural
Products(201203046) funded by Special Fund for Agro-scientific Research in the
Public Interest as well as the Restoration Technology Integration and
Demonstration on Disaster destroyed and Wastewater Irrigated farmland
(2011BAD04B04) funded by the National Key Technology R&D Program.

<footnote>[1]Li J., Xue L. :A study on navel orange grading system based on computer vision [J]. Acta Agriculturae Universitatis Jiangxiensis, 2006, 28(2): 304-307.</footnote>

<footnote>[2] Brosnan T, Sun D. W.: Improving quality inspection of food products by computer vision—a review[J].Journal of Food Engineering, 2004, 61(1): 3-16.</footnote>

<footnote>[3] Anderson T. :Back in the studio-Visual Studio 2008[J].Personal computer world 2007, 30(11): 148-149</footnote>

<footnote>[4] Christian N., Bill E. Professional C# 4.0 and .NET 4 [M]. Wrox, 2010.</footnote>

<footnote>[5]He C.H., Zhang X. F., Hu Y. C.: A study on the improved algorithm for Sobel on image edge detection [J]. Optical Technique, 2012, 38(3)323-327.</footnote>

<footnote>[6]Gonzalez.R.C., Woods.R.E.: Digital Image Processing, Third Edition[M]. Electronic Industry Press 2011.</footnote>

<footnote>[7]Gou X M, Jia X H Digital Image Processing, Edge Detection Technique [J]. Zhongyuan Institute of Technology, 2007 (6):64-70.</footnote>

<footnote>[8]Cao L P. Machine recognition of citrus variety based on the fractal dimensions of perimeter-area[J]. Transactions of the CSAE, 2010, 26(2):351-355.</footnote>

<footnote>[9]Cao L P, Wen Z Y, Shen L M. Sugar Content and the Valid Acidity Test of the Citrus Based on the Fractal Dimensions of Hue[J]. Transactions of the Chinese Society for Agricultural Machinery, 2010, 41(3):143-148.</footnote>

<footnote>[10] CODEX STANDARD FOR ORANGES. CODEX STAN 245. 2004.</footnote>