Qualitative Sorting of Potatoes by Color Analysis in Machine Vision System

Machine vision system is a modern technique that is used for grading of wide range of agricultural crops. Objective of this research is qualitative sorting of potatoes by means of lighting chamber, Camera, frame grabber and computer for catching proper images and analysis of them by MATLAB software. 110 numbers of Agria potatoes were selected randomly and placed in same lighting conditions. The images were transferred by frame grabber to computer memory to be analyzed. The samples had been pre-graded in the same face witch were placed in lighting chamber and percentage of health class was recorded. By performing pre-processing techniques on images, the compound of HSV color space and logarithmic transformation by coefficient of 0.5 was selected. The correction coefficient of health class of pre-graded method and results of implementing algorithm was 0.989 that it was the highest. Qualitative sorting accuracy in this method was 96.54%.


Introduction
Potato is a major food in the diet of world people.It provides carbohydrates, vitamin C, minerals, high quality protein and dietary fiber.Potato ranks fourth position in the world after wheat, rice and maize as non-cereal food crop.It is used in many ways like vegetable, potato wafers/chips, powder, finger chips, etc.The necessity of potato consumption (in any forms such as seed, bringing forward for selling in market, starch, livestock feeding, processing operation, etc.) provides the special condition for any forms of consumption.The objective of sorting is preparing this groundwork and providing proper conditions for any of applications.By creating these conditions, we are able to sort the crops in many aspects such as: size, shape, color, inner and surface damaging, etc.
Usually potato is sorting with training workers.This sorting method has some disadvantages such as: impressible by circumstance conditions, time and cost consuming.In response to one of the biggest challenge in present century i.e. preparing food demand of growing population in world, advanced technologies are implemented in agriculture.By developing modern technologies in agriculture, handy food quality evaluations are replaced with these modern technologies.Applying these technologies in agriculture have some advantages such as: time and cost saving, accuracy, capacity and yield increasing. Mechanical sorting is divided to two groups which are contacting and non-contacting methods.In contacting sorters crops usually are damaged.Contact with sorters is the cause of damaging of them.For this reason the non-contacting methods are preferred.Machine vision system is one of the non-contacting methods.The machine vision system is used by many researchers in food quality evaluation.Appearance of this system is coming back to 1960 decade (Brosnan & Sun, 2004).
Image processing and image analysis are the core of computer vision with numerous algorithms and methods capable of objectively measuring and assessing the appearance quality of several agricultural products.In general total appearance of an object consists of visual structure, color, gloss, translucency, their patterns and surface texture.Among these different classes of physical properties of agricultural products, color is visually considered the most important attribute in the perception of product quality.Color in image analysis is a powerful descriptor which facilitates recognizance and detection of objects.Color vision considerably is an important quality attribute, and is used as a predictor of quality and a standard of identification.We can create color properties of crops by testing any of the image pixels in crop threshold.Machine vision has been applied for measuring color in a wide range of agricultural products.For example some of these researches are referring below.
Von Beckmann and Bulley in 1978 developed an electronic sorter for color and size grading of tomatoes.They used the ratio of surface reflectance in wavelength of 600 and 660 nm to sort tomatoes in 4 grades (Von Beckmann & Bulley, 1978).
Miller and Delwiche in 1989, developed a color vision system for detection and sorting of ripe peaches.For peach sorting their color was compared to color of standard ripe peach (Miller & Delwiche, 1989).Laykin in 2002, used three methods for sorting of tomatoes.These methods were: Mean-Standard deviation, Slide Blocks and Quad tree (Laykin et al., 2002).
Deck in 1995 compared the color segmentation results of a Multilayer Feed Forward Neural Network (MLF-NN) and a traditional classifier for the color inspection of potatoes (Deck et al., 1995).
Tao et al., in 1995 represented a method for sorting of green and good potatoes.They used HSI color system.Samples of potatoes were sorted by experts and farmers.They used 40 numbers of green and good potatoes in training phase and 20 numbers for each grade in test phase.In training phase all 40 good potatoes and 38 numbers of 40 green potatoes and in test phase all 20 good potatoes and 18 of 20 numbers of green potatoes were sorted correctly.The results of human and machine detection were close (Tao et al., 1995).
A high speed machine vision system for the quality inspection and grading of potatoes has been presented by Noordam et al. in 1995.The vision system graded potatoes on size, shape and external defects.For color grading of potatoes they used Linear Discriminate Analysis (LDA) and MLF-NN techniques.Results of LDA and MLF-NN sorting techniques implementing for different variety of potatoes were respectively 86.8%-98.6%and 88.1% -99.2% (Noordam et al., 1995).
The main objectives of this research were: 1) Applying and evaluation intensity transformation functions 2) Assessing the effect of changing color spaces 3) Identifying 4 qualitative grades of potatoes by selecting the best intensity transformation functions and color spaces combination.

Materials and Methods
The first step in structure of the machine vision system is designing a lighting chamber.The next step is extracting image properties and finally applying a sorting algorithm to grade the samples.

System Hardware Scheme
In this research the components of the hardware were: 1) Lighting chamber 2) CCD camera 3) Frame grabber

4) Personal computer
Lighting is an effective key factor in image processing.Later processing and its results are affected by lighting method.Imperfect lighting makes synthetic effect such as image shadow and are cause of errors in image processing.Thereby steady lighting is necessary for creating background and object contrast.Significantly natural light is changed by climatic conditions, view point, day hour and geographical position.For light quality standardization we can use artificial light.In the design of lighting chamber in this research no outer light may enter into chamber.The light sort of this chamber is florescent.Four florescent lamps were placed in latter positions of chamber two of them in right and two of them in left.Degree of latter walls was 45  .There was a hole in the top of the chamber that the camera lens placed there.Digital and video cameras are powerful tools for image acquisition and color studies.Such cameras devote half of the transistors to green sensitively, and one quarter each to red and blue, emulating human vision which is most sensitive in the green portion of the spectrum.Thus, a digital color image is represented in RGB form with three components per pixel in the range 0 to 225 and conventionally stored using eight bits per color component.The three signals are nonlinearly transformed and electronically combined to produce a digital color picture (Russ, 2005).
Consequently, it is obvious that RGB signals generated by a CCD camera are device-dependent, i.e. each camera has its own different color sensor characteristics and produce different RGB response for the same image when it is displayed through graphic card of standard monitor (Segnini et al., 1999;Hutchings et al., 2002).
The camera which used in this research was a CCD camera, model 'Proline UK'.For transferring images to personal computer the frame grabber of CHATEAU model is positioned in the motherboard of computer.

The System Software
The software of this system is MATLAB 7.6.0.Algorithm of figure1, is applied for quality sorting of potatoes.

Sample preparing and image capturing
110 numbers of potatoes from Agria variety were prepared from Bostan abad Research center of Tabriz.In this Research the sorting of potatoes was offline.Before sorting, the samples were graded by experts.For image capturing, the samples were placed in lighting chamber in the same face which in pre-graded phase sorted by experts.The image resolution was 704*576 pixels.The images were transferred by frame grabber to computer memory and in the next step the images were analyzed by MATLAB software.

Intensity Transformation Functions
For increasing sorting accuracy and detection the classes, preprocessing operation was done.By applying these functions, intensity in first image is transferred to second intensity in the second image.The values in the range of minimum to maximum point in the first image is transferred to the range of minimum to maximum point in the second image and the values below the minimum and above the maximum point is transferred to minimum and maximum point in the second image.The class and size of the second image is the same of the first image.If the maximum point in second image is smaller than the minimum point, the second image will be negative.In this situation the intensity of any pixels is minuend from maximum point in first image and the result is the new intensity of second image.

Contrast Stretching Transformation
Little light, limited sensor dynamic range or wrong adjustment of lens aperture may be the causes of the low contrast.Increasing of image intensity dynamic range is the objective of applying the contrast stretching transformation

Logarithmic Transformation
In some cases the image dynamic range is exceeded from monitoring tool power.In this circumstances only the lightest part of images are visible.One of the effective solutions is compressing of dynamic range by applying the relation1.In this relation c is constant and r and s are respectively the Intensity values before and after of transformation.This function is displayed in figure2.

Analysis of Color Properties in Pixel classification
The selective method in qualitative sorting of potatoes is based on pre-graded of pixels to determinate classes and then sorting them to different grades.For extraction of health color thresholds, images divided to training and test sets.In training groups 220 numbers of 100*100 pixel windows extracted and introduced as samples of health class to MATLAB for pixel classification.To reach the best sorting accuracy, color spaces of RGB, HSI, YC b C r and HSV were evaluated.

Color Analysis
For color analysis, firstly the samples were pre-graded by experts.And then the samples were placed in the same face in the lighting chamber.Sample images were processed in MATLAB by implementing the algorithm (figure1).In this algorithm for color analysis of samples, different combinations of color spaces and intensity transformation functions were applied on the images and the percentage of health class was extracted.For calculating the percentage of health class, firstly the numbers of health class was recorded.Then by filtering the images and them edge detection, the numbers of total pixels that were in the region was recorded.The health class percentage is the ratio of health pixel numbers to the total numbers of pixels.