the increased awareness and sophistication of consumers have created the expectation for improved quality in consumer food products . this has increased the need of advance quality monitoring systems for quality detection and early warning for different type food samples . quality itself is defined as the sum of all those attributes which can lead to the production of products acceptable to the consumer when they are combined . the basic quality assessment is often subjective with large number of attributes such as appearance , smell , texture , and flavor , frequently examined by the consumers . . sometimes its demand increases at very high level in market due to low production or damage due to different disease attacks while as supply is limited . therefore there is an essential need of an advance system for detection of shelf life as well as also provides early warning from various diseases attacks . quality and productivity control is a big issue in tomato crop due existence of large number of diseases . most of diseases affect the outer area of the tomato flesh by some color change or different spots . in general there are two types of factors which can affect tomato fruit : living ( biotic ) and nonliving ( abiotic ) agents . different insects , bacteria , fungi , and viruses are the example of living agents . nonliving agents includes various environment effects such as rapid temperature change , excess moisture , insufficient nutrients , poor soil ph and high humidity conditions . in this kind of scenario vision sensing technique is one of the best as well as appropriate choice to avoid such kind of conditions . vision sensing technique is very powerful tool for such kind of application with efficient implementation . color distortion detection , cluster extraction , and entropy calculation are some of very useful techniques used in developed system for prediction of different parameters for tomato fruit . there are large numbers of diseases exists for tomato crop ; some of collected samples of different disease attacks are presented in figure 1 . it can easily be figured out that all four diseases affected the outer flesh area of tomato like in figure 1(a ) ; tomato is affected with early blight disease which generates the black color concentric rings and tomato flesh appearance changes to velvety color . late blight disease ( figure 1(b ) ) affects generally unripe tomatoes and it generates irregular brown blotches on the tomato outer surface . while as bacterial canker ( figure 1(c ) ) and gray mold ( figure 1(d ) ) affects the outer surface of the tomato like in first one tomato infected with white color spots while as later one generates the light gray spots on the outer wall of the tomato . experiments were conducted on the fifteen tomatoes divided in three batches taken from local market having different maturity levels . collected tomato samples collected samples have been preserved in different environment condition like first batch stored in the sampling chamber with constant temperature and humidity because there is an essential need to analyze the effect of environment conditions on different parameters like ripening rate , early warning , shelf life , and so forth . based on past research it can be concluded that at temperature 12c and humidity at 90% ripening rate is optimum . preliminary study showed that at constant 20c temperature and 90% humidity , the initial turning red color changed to deep red in the course of 7 - 8 days , in parallel with the softening process . second batch has been preserved in open environment at the room temperature and humidity ( t = 27c and rh = 20% ) for observing the environment effect on tomato quality . third and last batch have been preserved in refrigerator at 4c and humidity at less than 10% chilling environment . some of the images also have been imported from outside for generating the database of some special kind of diseases because of unavailability of such kind of environment conditions . database has been prepared for more than ten living and nonliving bacterial agents exist in tomato presented in table 2 . firmware development consist of two sections : first one is hardware development composed of developed arm based system with required experimental set up and second one is algorithm development using various algorithms required for sample classification , early warning about disease attack detection and classification . an arm based system consists of usb camera for image acquisition , white light source for providing light , touch screen with qtopia based gui for controlling purpose , movable slits for optimum light transfer , zigbee module for wireless image transfer , filters for changing the wavelength of light source , and a pc based server for analysis purpose . the whole setup was installed in black color aluminum chamber to avoid external light as shown in figure 2 . processor triggers the low power led based light source interfaced with waveguide before image acquisition . processor triggers camera via serial protocol based on the number of frames entered by the user . every image processor enables different filters for image acquisition in different color space like if processor enables red filter then captured image is in red light domain . this technique is very much useful for color extraction for tomato sample in different color space . light quality is key point in the image acquisition process for efficient and good quality image acquisition . a low power white light source has been installed in a waveguide for optimum light transfer inside the image acquisition chamber . after image acquisition has been completed then system transfers image on the pc based server using zigbee module . after image has been received on the pc based server , all image processing related techniques have been implemented by the system . different sample detection , classification , and disease detection based techniques execute on the received tomato sample image . based on the extracted results , server transfers quick subjections to the host systems . all experiments performed in a structured manner for efficient analysis and results for the consumer . algorithm development consists of sample classification having different subsections like preprocessing , region of interest extraction or segmentation and feature extraction . . algorithm development phase of the proposed system can be majorly divided into two phases : first one is training and second one is the testing part for the system . both training and testing require some kind of preprocessing . a higher level of abstraction block diagram for proposed algorithms has been presented in figure 4 . rank order filters have been used for cleaning as well as smoothing purpose ( see figure 3 ) . this section removes the noise as well as blur in the captured image . in this subsection , system selects a 3  3 mask and moves it on the whole image or it can be understood in more technical way that system performs the convolution of captured image as well as the kernel of the filters . as rank of the kernel increases , its noise removal ability also increases . all experiments have been performed in a structured environment , so there is very less possibility of noise mixing in captured image . still due to camera limitations , some of the blur was introduced in the captured image but for such kind of noise removal 3  3 kernels are enough . system implements noise removal algorithm from following equation : 
 ( 1)y(i , j , k)=i=3  i = h1j=3  w1k=1bg(i , j , k)p = i2  p = i+2q = j2  q = j+2r=1kinput(p , q , r ) , 
 where g  ( i , j , k ) is the kernel and input ( p , q , r ) is the input captured image for noise removal algorithm . all experiments has been performed in the structured environment inside the chamber , so background subtraction is efficient and optimum for implementing segmentation of region of interest extraction . in this process system captures two successive frames : first one without tomato sample at t time and second frame with tomato sample at t + 1 time : system subtracts both frames and extracts segmented image . it is convenient and effective method for detecting foreground object with stationary background : 
 ( 2)d(x , y , t+1)=i=1 i = nj=1  j = nk=13(v(i , j , t+1)v(i , j , t ) ) . feature extraction phase consists of different subsections like color extraction , texture entropy extraction , blots area calculation , and k - mean clustering for extraction of different clusters due to different diseases . any rgb image is a combination of red , green , and blue colors according to standard color space . so , it is advisable to extract percentage of red , green , and blue components out of all pixels . it helps to detect the maturity level of the tomato . as tomato moves towards maturity level , its color component changes with a variation of maturity level like initially tomato consists of high content of green color , while mature or ripen tomato consists of high content of red color . so using rgb color extraction method we can judge the maturity index of tomato sample . color extraction is also one of the major key points for detection of tomato sample . this method extracts a range of color from minimum to maximum concentration from captured tomato sample image . red , green and blue color concentration has been extracted using following mathematical transformations : 
 ( 3)r(x , y , z)=input(:,:,2)=0,r(x , y , z)=input(:,:,3)=0,g(x , y , z)=input(:,:,1)=0,g(x , y , z)=input(:,:,3)=0,b(x , y , z)=input(:,:,1)=0,b(x , y , z)=input(:,:,2)=0 . most of the consumers judge quality of the tomato sample based on the texture parameters . proposed algorithm consists of a texture detection subblock in classification phase . according to traditional information theory , entropy is a measure of uncertainly in a random variable . entropy is the degree of measure for unusualness presents in a local zone of a captured image . low entropy images , such as those containing a lot of black spots with very little contrast and large runs of pixels with same or different values . this can help for detecting unusualness existing in tomato sample area like a black spot or small bacterial speck . texture detection is performed on segmented captured image using entropy calculation method . in this method , first system performs grayscale conversion on segmented image . after grayscale conversion , system extracts local entropy of the image using traditional entropy calculation method . after the extraction of local entropy matrix the mean of the calculated minimum and maximum pixel range from local entropy matrix will act as texture quality coefficient . developed system is trained with wide range of texture quality coefficients extracted from different tomato sample images from prepared database : 
 ( 4)h(x , y , z)=i=1  i = nj=1  j = nk=13p(i , j , k)log2p(i , j , k),p(x , y , z)=i=1  i = nj=1  j = nk=13n(i , j , k)m2 , 
 where size of the segmented image is m  m and p(x , y , z ) is the calculated probability index matrix . this block takes care of the tomato sample detection as well as classification as well as detection of different diseases for tomato sample . in this process after binary image conversion , system applies hard thresholding for removal of unnecessary objects presents in captured image like leaves , trees etc . system estimates the area of the object in converted binary image and calculates approximate area of the object . calculated area is a scalar quantity , which corresponds roughly to the total number of on pixels in the image but might not be exactly the same because different presents of pixels are weighed differently . basically system estimates the area of all on pixels in the converted binary image by summing the areas of each pixel in the image . each pixel is part of four different 2-by-2 neighborhoods.pattern with zero on pixels ( area = 0).patterns with one on pixel ( area = 1/4).patterns with two adjacent on pixels ( area = 1/2).patterns with two diagonal on pixels ( area = 3/4).patterns with three on pixels ( area = 7/8).patterns with four on pixels ( area = 1 ) . cluster detection has been implemented for detection as well as classification for different clusters presents in tomato food sample due to different microbial diseases . k - mean clustering algorithm has been implemented for cluster extraction and using different feature extraction methods system classifies different clusters ( see figure 5 ) . basically k - mean clustering algorithm classifies the objects ( collection of different pixels ) into the k number of classes based on a set of features . the classification is carried out by minimizing the sum of squares of distances between the data objects and their corresponding clusters . then system classifies different colors using k - mean clustering in  lab  space . after that system performs labeling process in the segmented image based on the results of previous step . basically k - mean clustering algorithm selects random mean pixel in every cluster presented in processed image and finally extracts the number of clusters presented in image based on the value of k that is why k should be chosen smartly . developed system has been initialized by k = 4 ; it means developed system detects only four clusters in every tomato sample . it has been observed that k = 4 are able to extract all possible clusters presents in tomato sample . after this whole process system moves mean pixels towards their corresponding clusters based on the calculation of minimum euclidian distance presented as follows : 
 ( 5)(e.d.)2=min{1k}i=1  i = nj=1j = n|x(i , j)2|,h=i=1i = np(i)ii=1i = np(i ) . basic learning algorithms have been implemented for supervised neural networks that are a great use of solving pattern recognition problems . various pattern recognition algorithms like pca , lda , and qda have been implemented for detection as well as extraction of various patterns generated in different tomato sample frames . principle component analysis is basically a statistical procedure that uses orthogonal transformation to convert a set of observations of possibly correlated variables in to a set of values of linearly uncorrelated variables called principle components . the number of principle components is less than or equal to the number of original variables . the transformation is defined in such a way that the first principle component has the large possible variance ( i.e. , accounts for as much of the variability in the data as possible ) , and each succeeding component in turn has the highest variance possible under the constraint that it is orthogonal to ( i.e. , uncorrelated with ) the preceding components . developed system performs pca on segmented tomato samples image and generates different principle components for classification : 
 ( 6)c(x , y)=q=1nx(q , x)x(q , y),det(c(x , y))=0 , 
 and generates eigenvalue 1  n , and eigenvectors v1  vn(7)v=[v1  vn],y = xv lda helps to predict the group membership for a number of subjects from a set of predictor variables . group variable also acts as a categorical variable , which extracts different data sets collected from segmented tomato sample images . linear discriminant analysis constructs one or more than one discriminant analysis di ( linear combinations of the predictor variables xk ) such that the different groups differ as much as possible on d : 
 ( 8)di = b0+k=1pbkxk . more precisely , the weights of the discriminate function are calculated in such a way that the ratio ( between groups of sample space and within groups of sample space ) is as large as possible . n and same as second discriminate function d2 distinguishes first group from groups 3 ,  , system calculates the optimal weights using a training set consisting of correct classification for a group of datasets of the different tomato samples . after this process , system classifies different data sets using previously calculated discriminate weights to obtain their discriminate scores . some datasets are too much complex due to close stages of tomato samples , so sometimes lda is not able to discriminate such kind of data sets . quadratic discriminant analysis has been implemented to discriminate very much complex data sets of the tomato samples . all the steps in lda and qda are same except the classifiers . in lda linear classifier qda provides more discrimination capability to the developed system but at the same time it also acquires more memory as well as more processing time . lda needs to estimate kxp + pxp parameters while qda needs to estimate kxp + pxpxp parameters . general structure of classifier used in qda implementation presented as follows : 
 ( 9)yqda = argmink=1,  ,k{(xk)tk=1n(xk)2log(k)bbbbbbbbbbbbbbbbbbbb+logzk=1n(xk)2log(k)},z=1nkk=1n(xk)(xk)t.k - nearest neighborhood learning algorithm is also implemented in the proposed algorithm . whenever system has a new point to classify , system find its k - nearest neighbors from the training data set . after that system measures the euclidian distance between pixel and its nearest neighbors from training data set . distance can be measured by any one of the following distance methods.euclidean distance.murkowski distance.mahalanobis distance . implemented algorithm used euclidian distance for measuring the distance between nearest neighbors from training data set and operation of pixel . pca , lda , qda and knn have been implemented on four tomato samples having different maturity levels like unripe , ripen , fully ripen and rotten presented in figure 6 . total collected tomato image samples are 100 in that there are 62 healthy tomato samples and 38 tomato image samples are infected from different kind of diseases . the method implemented in this research paper is much effective and fast compared to other implemented vision sensing systems . developed graphical user interface predicts different important parameters related to texture , color , freshness , maturity index , and disease attacks as shown in figure 7 . developed system is one of the effective as well as fast methods for quality detection of tomato samples using vision sensing technique . the overall results were satisfying and it can be considered as a successful development of system . presented method is unique in sense of tomato sample detection using different color extraction methods , texture detection methods , and different disease detection and classification methods . a flow of developed algorithm based on extracted results has been presented in figure 8 . various parameters have been extracted from developed algorithms such as color index and texture index ( entropy ) , presented in table 3 . it has been observed that color index and entropy calculation is sufficient for maturity index assessment for tomato fruit . infected and healthy tomato samples can segregate based on various extracted parameters such as color index , texture index , and area calculation . it can be observed in figure 9 that developed system can classify between healthy and infected tomato fruits . extracted results have been also validated with standard alpha mos and ultrasonic based stiffness detection system using aroma and ultrasonic sensing techniques , respectively . it has been observed that extracted results from vision sensing system are very close to alpha mos aroma sensing system results . most of the prediction and results are correct or very close to correct . as a conclusion , this research is strongly recommended to be used for early detection of tomato disease using developed system . tomato sample images are processed to determine the healthiness of each tomato sample as well as its plant . it can predict the attack of disease for tomato sample before the damaging of its crop . developed system can reduce the use of harmful chemicals on the tomato crop and hence ensure a healthier environment and maybe even lowering the production cost of the maintenance and producing a high quality of tomato .
producing tomato is a daunting task as the crop of tomato is exposed to attacks from various microorganisms . 
 the symptoms of the attacks are usually changed in color , bacterial spots , special kind of specks , and sunken areas with concentric rings having different colors on the tomato outer surface . 
 this paper addresses a vision sensing based system for tomato quality inspection . 
 a novel approach has been developed for tomato fruit detection and disease detection . 
 developed system consists of usb based camera module having 12.0 megapixel interfaced with arm-9 processor . 
 zigbee module has been interfaced with developed system for wireless transmission from host system to pc based server for further processing . 
 algorithm development consists of three major steps , preprocessing steps like noise rejection , segmentation and scaling , classification and recognition , and automatic disease detection and classification . 
 tomato samples have been collected from local market and data acquisition has been performed for data base preparation and various processing steps . developed system can detect as well as classify the various diseases in tomato samples . 
 various pattern recognition and soft computing techniques have been implemented for data analysis as well as different parameters prediction like shelf life of the tomato , quality index based on disease detection and classification , freshness detection , maturity index detection , and different suggestions for detected diseases . 
 results are validated with aroma sensing technique using commercial alpha mos 3000 system . 
 accuracy has been calculated from extracted results , which is around 92% .