Short communication. Automatic inspection of the pomegranate (Punica granatum L.) arils quality by means of computer vision

With the aim of ensuring the quality and homogenising the colour of commercial batches of pomegranate arils, a new prototype for the automatic inspection of pomegranate arils and their separation into categories by means of air ejectors has been developed. Arils are singulated and transported on conveyor belts. Images of the arils are acquired using two cameras to allow estimation of the quality and are then expelled through different outlets according to the category. New control software were developed that synchronise the advance of the conveyor belts, the acquisition of images and the separation by air ejectors, which also includes mechanisms for the synchronisation and communication between the vision and control computers. A new computer vision system has been developed for the inspection of arils that distinguish between arils and raw material by estimating the colour of the objects and then classify the arils by size and colour. The prototype was tested over a six-month period in a Spanish pomegranate producer, with the inspection of about 5 Mg of product. The new prototype achieves the objective of inspecting and sorting pomegranate arils according to their quality, reaching the performance specifications. Additional key words: image analysis, machine vision, on-line sorting, quality.

the arils, which produces rejection by the consumer in favour of other fruits that are easier to prepare.One solution for this fruit could be the marketing of pomegranate arils ready for consumption.This would allow the introduction of a new product, with a high added value, onto a market in which consumers' interest for this type of products is increasing.Since the colour is the natural sense used to make the first evaluation of the quality of fruits, most of the inspection systems use only this feature to segment the images (Blasco et al., 2007a;Lee et al., 2007).In order to make a product that is more attractive to consumers, all the arils in the same package should have a homogeneous colour and there should be no foreign objects as membranes or flawed arils; to achieve this, the automatic inspection and classification of the arils would be necessary.
Machine vision has been largely employed for the inspection of the quality of fresh fruit (Brosnman and Du, 2004).However, although similar work has been conducted on other produce easier to singulate as olives (Díaz et al., 2004), the authors have not found any other kind of machines for the inspection of fragile produce such as arils.Most of the work about processed fruit is related to the inspection of mandarin segments (Galindo et al., 1997;Blasco et al., 2007b) or canned peaches (Aranda and Tomás, 1997;Vizmanos et al., 1997).The main reason for the absence of related work in the literature is probably due to the great importance of fresh fruit compared to the relative low production of processed fruit (Aleixos et al., 2002;Blasco et al., 2003Blasco et al., , 2007c)).
The Agricultural Engineering Centre of the IVIA and the pomegranate producer Frutas Mira Hermanos, S.L., collaborated in the design of a prototype, based on computer vision, to inspect and separate pomegranate arils automatically depending on their quality.Foreign objects, such as pieces of skin or inner membranes, also have to be detected and separated from the good arils.
The aim of this work was to develop a prototype for the automatic sorting of pomegranate arils, including the development of a new real-time computer vision system for evaluation of individual arils, as well as tools for controlling the prototype and for synchronising the inspection with the output system.The prototype must be capable of ensuring a minimum production of 100 kg of arils per hour.Computer vision algorithms have to estimate the colour of each aril individually, and must be capable of discriminating between arils, pieces of skin and internal membranes.The control algorithms have to manage the synchronisation between the image acquisition from two different cameras, image processing, the movement of conveyor belts and air ejectors activation.Most of the problems encountered in handling pomegranate arils are related to their small size and the large numbers of arils needed to reach commercial production, which make it difficult to separate them into different categories.
A whole prototype for the inspection of pomegranate was designed and constructed (Fig. 1, left).The prototype consisted of three modules for singulating and transporting the arils under the cameras and separating them into user-defined categories.
The arils enter in the machine piled onto a single 250 mm-wide conveyor belt.They then are moved to the inspection prototype, which has four 50 mm-wide conveyor belts.The splitter consists of a stainless steel piece constructed with one input that separates the arils into four outlets, similar to four linked funnels where the arils come in at the upper part, and are divided as they fall down over the conveyor belts under the effect of gravity.The high speed of the system separates the arils as they drop onto the conveyor belts (Fig. 2).The speed of the four conveyor belts that transport the arils through the prototype is regulated by means of a variable frequency drive between 0 and 1.5 m s -1 .
The arils represent the objects of interest in the images while the conveyor belts are the background.To allow good image segmentation, it is very important to choose the colour of the conveyor belts adequately.Conveyor belts on different colours were tested before fitting the conveyor belt on the prototype.Images of arils and membranes over pieces of conveyor belts in white, blue, dark green, light green and grey were acquired and segmented by means of a threshold, which was different depending on the colour (Fig. 3).To select the most adequate background colour, the segmentation of the images acquired using the different conveyor belts was visually evaluated by trained operators.
Using conveyor belts on white colour, the vision system confused the internal membranes with the background.In the case of dark green and grey, those arils with darker colours were also confused with the background.However, using the blue and light green conveyor belts all the arils and raw material were correctly segmented, being better in the case of the blue conveyor belts.Consequently, the prototype was set up using conveyor belts of this colour.
The system uses two progressive scan cameras that acquire red, green and blue (RGB) images with a size of 512 × 384 pixels and a resolution of 0.77 mm pixel -1 .Both cameras are connected to a personal computer  (Pentium 4 at 3.0 GHz) by means of a single frame grabber that receives the images and passes them to the computer's memory.The scene is illuminated by four fluorescent tubes placed on both sides of each conveyor belt, and which are powered by means of high frequency electronic ballast to avoid the flicker effect.Polarising filters are used to minimise the influence of bright spots and shines in the scene that can alter the perception of the colour by the inspection system.The scene captured by each camera, which includes two conveyor belts, has a size of approximately 400 mm along the direction in which the conveyor belts advance.All the software for the acquisition and real-time image processing of arils was developed using the C programming language.The purpose was to optimise the acquisition time of both cameras by analysing the images to determine the quality of the arils, minimise the image processing time and send the result of the evaluation of the arils to the control system.
Algorithms to control the prototype were also programmed using the C programming language and implemented on a secondary computer.This computer controls the movement of the conveyor belts by means of an encoder that is attached to the axel of the guiding rollers and connected to the parallel port of the computer.The computer reads the parallel port and from the number of pulses can calculate the exact position of the conveyor belts.
The grading area (Fig. 1, right) is located after the inspection chamber.Attending to commercial parameters, three drops were placed on one side of each conveyor belt and another at the end.In front of each outlet, at the other side of each conveyor belt, air ejectors are placed to expel the arils.The air flow is regulated by electro-valves that are controlled directly by the control computer using two auxiliary parallel ports (each electro-valve is connected to an output pin of the parallel port).When the computer estimates that a specific aril is going to pass by the chosen outlet, it activates the appropriate pin of the parallel port.Then, the electrovalve is activated and the aril is moved to the outlet.
Pomegranates for testing the prototype and indications about the features of each category were provided by the fruit company.The first tests of the prototype were carried out using 0.5 Mg of fresh pomegranates (cv.Mollar de Elche), from which the arils were extracted manually.During the tests in the industry, the arils of about 7.2 Mg of fresh pomegranates were inspected and classified in the following four categories: (i) defective arils, usually consisting of rotten arils that were brown, (ii) weak arils, semitransparent white arils, normally small in size, (iii) first category, good quality arils with a soft-pink to intense pink colour, and (iv) extra, good size arils with an intense red colour.During the extraction process, raw material, such as internal membranes or pieces of peel that are carried along with the arils, must be separated from the good arils, which constituted a fifth category.
The background colour of the images, which corresponds to the conveyor belts, is blue.When this colour is measured in RGB coordinates the main component is B, while the lowest value usually corresponds to the R component.Pomegranate arils are red, and therefore have a high value of the R component.Consequently, the image segmentation technique employed was based in a thresholding in the R band of the image.
In the next step, the contour of the objects of interest is extracted to make a decision about the type of object (aril, membrane, skin piece, etc.) based on the estimated area and perimeter.If the object is above or below a certain threshold size, it is considered to be raw material and the analysis ends for this particular object.The higher threshold was determined using basic statistics as the average and typical deviation of 5 kg of arils inspected by the prototype.The lower threshold was established by experienced workers of the producer company which empirically considered that an aril smaller than a particular size must be rejected.The averaged colour of the remaining objects, which are considered to be potential arils, is then estimated to decide the category.The sum of all the R and G components of the pixels belonging to the object is calculated and averaged to estimate the colour using the ratio R/G.Normally the highest values of this ratio come from dark red arils while the lower values are from white arils or membranes.The thresholds for splitting the categories were established depending on the general quality of the arils and were changed along the season, since the colour of the arils evolves quickly throughout the season.
Both the location and the quality of each object are sent to the control computer following a specific protocol implemented using TCP/IP (Transmission Control Protocol/Internet protocol).The information about all objects found in one image is sent in a single package, including the belt number, the location and the quality of each object.The system analyses about 10 images per second.
The results of the laboratory tests showed that the prototype is capable of correctly separating objects travelling at a speed of 1 m s -1 if these are separated by a distance of at least 20 mm.The ejection of one object can affect others nearby if they are closer than this minimum distance of 20 mm.Having a spacing of 20 mm between consecutive arils, the system can inspect 50 arils m -1 .With a conveyor belt speed of 1 m s -1 and an averaged weight of a single aril of 0.4 g, the prototype is capable of inspecting 72 kg of arils per conveyor belt.Since it has four conveyor belts, the theoretical performance of the prototype is around 288 kg h -1 .However, due to problems related with an irregular feeding of the arils, the estimated actual performance estimated during production tests was about 110 kg h -1 .
The prototype was tested in the fruit company over a period of 6 months, between September and February 2004/2005.During the tests, the prototype inspected 5.2 Mg objects (arils and pieces of skin).It is unviable to evaluate the result of the individual classification of each aril due to the great number of them and the subjective criterion of separation between the categories.For this reason, the evaluation was performed visually by experts at the producer company who analysed the arils from the different outlets.In general, the membranes are well distinguished from the arils, but differentiation between the different categories of arils depends on the expert who carries out the evaluation.The arils in the «extra» category were considered as being well classif ied, whereas it is necessary to improve the system to classify correctly the rest of categories.

Figure 1 .
Figure 1.General picture of the prototype developed at the IVIA for the inspection of pomegranate arils (left).Grading area showing the air jets and the outlets at both sides of the conveyor belts (right).

Figure 2 .
Figure 2. The arils get the prototype piled up in a single conveyor belt (left).Before entering the prototype the arils are split into four narrow bands (right).

Figure 3 .
Figure 3. Conveyor belts of different colours were tested to enhance the contrast between the objects of interest and the background, saving further image processing time.