THRESHOLD SEGMENTATION USING MODIFIED 2D-OTSU PSO ALGORITHM

Median filter is a technique which applied to remove impulse noise in image processing. Filtered images are carried out to the next level of operations, such as segmentation and object recognition, etc. In this study chili x-ray images are taken for analysis. The chili x-ray images were preprocessed using existing algorithms such as Average filter, Median filter, Wiener filter, Gamma intensity correction and CLAHE, and proposed algorithms such as 4-connected Median filter, weighted 4-connected median filter and Optimized connected Median filter using PSO. Texture regions are extracted by gabor filter. From the extracted texture regions Modified Range filter along with Adaptive Particle Swarm Optimization were applied to extract textures. To perform the next level operation such as segmentation, fixed threshold and Otsu threshold with PSO were applied. However seeds and fungus affected portions of chili x-ray images were not clear. To overcome the above problem this research paper proposes a well-organized algorithm and it is known as modified 2-D Otsu PSO algorithm. It performs better than the previous threshold algorithms. Performance measures are taken to prove that the proposed algorithm works better than the previous methods.


INTRODUCTION
Threshold is a process used to convert image pixels into black and white is known as binarization [1]. Threshold value obtained as higher than the value of the image pixel than the particular image pixel was converted into white. Likewise Threshold value obtained was lower than the value of the image pixel than the particular pixel was converted into black [12]. It is a very simple and an important process in the recognition pipeline [6]. The performance of a threshold process shows directly its impacts on the classification process.
Images taken in real-time environment may consist of various artifacts such as shadow, background noise, contrast variation level etc. Accurate binarization of the images taken in real-time environment is very complex and important one. Separating the object from the noise background is a challenging work under various circumstances [15]. An improper selection of threshold interprets the object wrongly as noise and interprets the noise wrongly as object. This will turn into degrading performance.
Otsu's method of threshold is the most powerful and global threshold method. It performs image binarization based on the histogram shape of an image. Otsu algorithm assumes that the image for binarization contains only foreground and background pixels [5]. It computes the optimal threshold by minimizing the intra-class variance that separates the foreground pixels from background pixels [10].
In the prior research work, Particle Swarm Optimization has effectively implemented in many application areas. Now, the PSO algorithm has applied to resolve the crisis of threshold segmentation. Zahara et al. [7] employed the PSO algorithm to select the threshold of an image with multimodal histograms. P.Yin [13], finds the optimal threshold by calculating cross entropy by using PSO algorithm. Sathya et al. [14] proposed multi level threshold segmentation based on PSO algorithm with the image histograms. Hongmei et al. [17] proposed an improved PSO algorithm to segment images by adopting the maximum entropy. AndreL et al. [3] proposed color image segmentation based on image entropy.
In this proposed work toxin contaminated and uncontaminated chilies were taken. These chili x-ray images were preprocessed by some existing algorithms and also with the proposed preprocessing algorithms. After preprocessing the chili x-ray images were texture segmented [2] using gabor and range filter. Subsequent to range filter process the images were binarized with fixed threshold method. Following to the threshold process of an image, the results obtained for the chili image segmentation was not in acceptable manner. Because some of the chilies were contaminated and the position of the seeds were covered by the fungus which seems difficult to predict well. To improve the image quality, the selection of threshold value for binarization was further improved by applying particle swarm optimization with Otsu algorithm. The result of the above process also contains unclear seeds in chili x-ray images. Fitness function in the particle swarm optimization was slightly modified to obtain better segmentation results. Finally the binarized chili x-ray images were processed by some morphological functions to provide better segmentation results.
The present study has organized in the following scheme: section 2 deals with the proposed method used, the results and discussions are explained in section 3, whereas the final conclusions are explained and in section 4 all the references taken for the study were given.

BINARIZATION ALGORITHMS
In order to reduce the complexity of classification, the gray scale image was converted into binary image by a selection of threshold value. Binarization can be achieved either by the function of local threshold or global threshold algorithms [3]. Figure 1 shows the block diagram of the binarization method. In the fixed threshold method one threshold value was given for the entire image. On the implication of one threshold value, the entire image pixels are classified into black and white i.e., foreground and background. This can be written as follow in the equation 1.
T(x, y)= (1) where refers the image pixel of the input image and T(x,y) refers the pixel of the thresholded image.

A. Fixed threshold method
In this threshold method, a particular intensity value was used as a separator, i.e., the image pixel values were clustered into two sets, namely foreground and background [9]. On the trial error method, an optimal threshold value was selected to do the above function. The threshold value selected was a scalar number and it was applied to binarize the image by using the following equation 2.
where I b (x, y) refers the binarized image and T refers fixed threshold value selected by the trial error method.

B. Otsu Algorithm.
The main aim of Otsu Algorithm is to find the threshold value where as the sum of the foreground and background value spread out has to be minimum [7]. Threshold value T is obtained by Equation 3. T = (3) where μ 0 refers to the average grey value of the object point, μ 1 refers to the average grey value of the background point, μ refers to the total mean of the whole image [5].

C. Proposed threshold algorithms
In the image processing techniques, there are many applications are used to differentiate the foreground from the background by employing their gray level value of pixels. Among them threshold is an important and efficient tool to do the above mentioned function [21]. Threshold function can be done by many methods. Each method has its own advantages as well as disadvantages. Among the various methods Maximum class square error is an efficient method to find the perfect threshold where the pixels of the image in a group are close to one another [20]. Despite finding of correct threshold for efficient separation of foreground from the background leads to optimization problem. In order to overcome the above stated problem Particle swarm optimization was employed in the proposed research work. Earlier studies also employed particle swarm optimization for the same kind of problem [8].

PSO algorithm
Particle swarm optimization is a best optimization algorithm was developed by Kennedy and Eberhart. It is a very simple and well known algorithm [11]. The model of PSO has been designed in such a manner to attain the maximum benefits from its nearby particles. It can be easily implemented and applied to solve many optimization problems.
Let X and V refer to the particle's current position and velocity respectively [4]. At the iteration m, each particle position j is noted by and a velocity is noted by in the entire search space n. Position of each particle and velocity is updated by using the equations (4) and (5) as follows.
(4) (5) where m is the current iteration number, c1 and c2 values are chosen as equal to 2, w is the energy weight and r1, r2 are the random numbers generated in between [0,1].
The fitness function of each particle are obtained as follows in the equations (6), (7) and (8).
where p is obtained from particle's position which lies between 0 and 255. refers the number of pixels whose gray value is less than p, refers the number of pixels whose gray value is greater than p, is the average of pixels whose gray value is less than p, is the average of pixels whose gray value is greater than p, is the median of pixels whose gray value is less than p and is the median of pixels whose gray value is greater than p. Implementation of PSO algorithm: The PSO algorithm starts its functions with randomly generated population. Each Particle position and velocities were initialized. Objective function was calculated by using equation (8) i.e. maximum value of fitness functions f 1 (g) and f 2 (g). The pbest and gbest are two important variables which represent the best particle position in local and the best particle position in global respectively. The proposed PSO algorithm was given below: Algorithm Step 1: The particle position and their velocity are initialized.
Step 2: Using the equation (8) compute the objective function.
Step 3: The local and global best position of particles were updated. Search the maximum value which satisfies the condition f(pbest) < f(x j ). Continue the search until f(pbest) < f(gbest) reaches and record the corresponding particle position as best threshold value.
Step 4: Update the particle position and velocity using the equations (4) and (5).
Step 5: Repeat steps 2 to 4 until stop criterion is satisfied or the desired optimal result has been reached.

D. Morphological operations:
The aim of morphological operations is to obtain perfection on improper structure of an image [19]. Morphological operations such as Close, Majority, Thicken, and Remove are used in this research. The Closing operation is applied to bring the smooth sections of contour in the chili binary image. It fills the gap in the contour by the process of eliminating the small holes. The Closing is computed by using the following equation (9). B) (9) The Majority is another morphological operation which sets a pixel value as one when five or more neighborhood pixels have the value of one. On the contrary it sets pixels value as zero.
Thickening operation helps that to strengthen the selected portions of object pixels of chili binary image. Thus the thickened chili binary image contains original chili image pixels and additional strengthened object pixels. The Thicken is calculated by using the following equation (10).
(10) The Remove is another morphological operation which is used to remove interior pixels of an image. It retains the outline of the image shape in the neighborhood.

IMPLEMENTATION RESULTS AND DISCUSSION
The images are undertaken to threshold through the algorithms which are shown above. To evaluate these algorithms two performance measures were taken such as Uniformity, Gray level contrast, Precision, Recall and Accuracy were taken. A Mean value of these measures were taken as standard for the final evaluation criteria. If the mean value is greater, then it indicates that the threshold segmentation result is good. Uniformity Measure: A good threshold selection divides the image into unique region parts. Each region has uniform property [22]. It is measured using the following equation (11).  (11) where Mx, My are the dimensions of the input image and X is the input vector. Gray-Level Contrast: Threshold image segmentation is dividing the image into two different is bigger, the graylevel contrast is bigger [22]. And the performance of the threshold segmentation algorithms is evaluated by using the following equation 12. gc = (12) where f f represents the mean of gray value of foreground object and f b represents the mean of gray value of background. The high gray level contrast indicates better segmentation result obtained through threshold algorithm [4]. The Precision, Recall and Accuracy measures are calculated by using the following equations (13), (14) and (15) Precision= (13) Recall= (14) F1= (    The threshold segmentation results for the Optimized connected Median filter using PSO are shown in figure 10

Discussion
In this research work 50 chili x-ray images were taken. Among them 25 were contaminated and 25 were uncontaminated. The contaminated chili seeds were surrounded by fungus. Uniformity, Gray level Contrast, mean value of the both, Precision, Recall, Accuracy were taken as performance measures to verify the segmentation results. From the comparison of the above tables, it infers among the three filters, 'Uniformity and Gray level Contrast and their mean value, Precision, Recall, Accuracy of the Weighted 4 connected median filter has obtained higher performance measure than the others. The implementation of Fixed threshold shows more seeds in the Optimized connected Median filter using PSO, little lesser seeds in the Weighted 4 connected median filter and a very low seeds in 4 connected median filter. The same result were obtained for the Otsu threshold and Modified 2D Otsu PSO. However in comparison of the seeds structure appearance in the chili x-ray images, Optimized connected Median filter using modified 2D Otsu PSO has clear appearance of more seeds than the others. Hence Optimized connected Median filter using modified 2D Otsu PSO provides better segmentation results than the other threshold methods.

CONCLUSION
Segmentation is a process which partitions the image into several meaningful parts. Threshold segmentation divides the image into two levels i.e below the threshold level are turned into black and above the threshold level are turned into white. In this proposed work 50 chili images were taken for the segmentation purpose. These 50 chili images were preprocessed with the existing filters and the proposed methods. The preprocessed images were taken for the segmentation process. Texture regions are extracted by gabor filter. From the extracted texture regions Modified Range filter along with Adaptive Particle Swarm Optimization were applied to extract the textures. Further the chili x-ray images were segmented by fixed threshold method. The performance metric obtained was high however the images of the seeds are not clear and visible manner. In addition to the above process PSO and Otsu are adopted to improve the chili images. Yet the inner structure of the chili images is not in the proper manner. Now the fitness function of PSO is slightly modified to overcome the above drawback and it is applied to the threshold selection. The resultant images structure is clear and understandable than the previous methods. Performance measures were taken and are uniformity, gray level contrast, average of both, precision, recall and accuracy. The performance measure results were also ensures the same. Finally the researcher concludes that the Optimized connected Median filter along with modified 2D Otsu PSO provides better segmentation results.