{'fraction_non_alphanumeric': 0.027939233817701453, 'fraction_numerical': 0.006803170409511229, 'mean_word_length': 4.630717738936408, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Novel Food Image Segmentation Based on Homogeneity Test of K-Means Clustering

Data clustering is an important machine-learning topic. It is useful for variety of applications one of them is image segmentation. A given divided image into regions homogenous additional to certain features is the image segmentation process, which matches real objects of an actual scene. FIS (Food Image Segmentation) is important for calories estimation. K-means has been used for performing such task. However, in order to conclude the food items number in the image, it requires interacting with the application. This article, presents a novel approach based dependently on k-means named Hk-means (Homogeneity test of k-means) is developed to calculate k value and applied for FIS for the purpose of assuring full autonomy in the calories estimation system. This approach uses the homogeneity test so as to compensate the new item existence in the image. The suggested method Hk-means is tested on food images and show accuracy 96%. The experimental results has achieved 1.5 second execution time when compare with benchmark method.


Introduction
Image segmentation is an emerging computer visualization application. It has found interest in a variety of resources such as medical field, diagnostics based on vision data [1], [2], industrial processes such as assembly line calculations [3], [4], agronomy [5], [6] and forensic image analysis data for operations of crime [7]. Image segmentation is the process of segmenting a given image into related locations in relation to specific features, and in the hope of harmonizing with the realities of the scene. In fact, image classification is used to provide simple and easy-to-follow data for the stages of a standard pattern recognition program [8]- [11], [30].
Classification is still a challenging topic for research in computer vision [12]- [15]. In addition to the existence of various types of image classification methods in the literature, there are drawbacks and challenges that can be addressed. Another difficulty in using the components of the algorithms is the lack of information about the specific range of specific chemical algorithms. This is handled in some cases by enabling the segmentation algorithm to work under certain assumptions. Unfortunately, this does not correspond to the requirements of the utility and the type of implementation of component algorithms. Therefore, there is a great need to develop existing segmentation algorithms to handle a portion of unknown parameters in the application context by incorporating additional algorithmic processes.
Data integration is one of the most important and popular methods of data analysis. Data records are grouped into nontagged sets over similarities [16], [17]. Integration is used in many fields such as [18], [19]. The k -tested algorithm was proposed by MacQueen [20] which was used to classify images into several locations as calories measured [21]. In this research article, we deal with the classification of food images in the context of an unknown number of foods. In the classical literature on segmentation, methods have been adopted to perform the segmentation after assigning it to a feed number. However, the plate may contain a voluntary amount of food items depending on the user's preference or desire. Thus, the kmeans are at greater risk of not knowing about the parameter k that represents the number of food items. Because of this, it is important to develop a new food separation method to manage this component. Also, this method should not be costly depending on the processing time considering that the amount of data is large in images. The purpose of this research article is to add statistical processing to the k-means to make it useful in distinguishing the food plate from the unknown food number. The analysis of the calculations will depend on the color distribution of the materials by considering the different color space according to their significance. It is important to extend the feature vectors of features to include color features that allow for additional information about the color distribution of the object and therefore help in avoiding local minima.
The organization of the article is as follows. In Section 2, the domain is assigned. The related activities are given in section 3. The methodology is given in section 4. The results are given in section 5. Finally, a summary and conclusion are given in section 6.

Background
In this section, a summary about segmentation based on k-means is provided. Next, the limitations of k-means based segmentation are discussed with some visual examples.

K-means based Segmentation.
Let X={xi},i=1,…n represents a set of n-dimensional points. In image segmentation each xi denotes one pixel in the image. While the dimension of xi denotes the number of colour spaces used in the segmentation. The image contains k food items. We denote each cluster as cn and the mean of each cluster as un. The image segmentation is performed to minimize the error that is represented in the "Eq.(1)".
The problem is then formulated as how to find the points un; n=1,..k where the value of J(C) is minimum. The following steps are performed to resolve the k-means problem.
 Select initial k clusters. u n ;n=1,..k  Generate a new cluster by placing each pixel to its closest cluster centre.  Compute new cluster centres. If (converged) go to 4, else go to 2.  Result is current clusters.

Limitations of k-means
One of the problematic limitations of k-means in the context of image segmentation is lacking of pre-knowledge about the number of clusters, which denotes the items that are to be segmented. k is the most critical choice when performing k-means clustering; wrong values of k might lead to local minima [22], [23]. In the literature numbers of heuristic approaches have been proposed for selecting k. A brief discussion is provided in the related work section.

Releted Work
In the literature, various methods have used image classification methods. Some of them deal with the problem of determination k and provide some solutions to those problems. Ray and Turi [24] introduced a new classification algorithm based on the intra-cluster and inter-cluster distance resulting in the automatic determination of clusters. However, the problem with this method is its complexity of the attribute as it requires producing all images separated into 2 clusters until they reach a large number of clusters when using a validation scale to determine which combinations are best when the validation rate gets the smallest value.
According to the authors [25] the authors propose new algorithms that efficiently investigate the spatial location of overlapping regions and the number of clusters in order to optimize the terms of the Bayesian information criterion (BIC) or the Akaike information criterion (AIC) measures. This method performs a series of experiments on the performance of k-data starting from a low probability and continues to be tied up (taking every opportunity) by calculating the means of each case for the best choice. As a result, this adds a computational overhead to an algorithm such as [24]. In addition, other researchers have shown BIC dysfunction in comparison to other methods. For example, Hamerly and Elkan [26] have run multiple kmeans in the data and performed statistical tests to make sure that each group follows a Gaussian distribution. This method works well compared to the BIC-based method; however, it suffers from some limitations. First, in order to have a reliable test of the hypothesis that the data are Gaussian distributions, it is important to have an adequate number of samples in each cluster. Unfortunately, this doesn't always work especially when the data corresponds to a small object size and the image resolution is low. Also, performance-based methods have been found to address the problem of finding the sum of clusters.
The authors in [27] proposed an edge detection as a way to determine the number of clusters when performing a ksegmentation. Only long edges are used to determine the collection value based on color matching. The average color of each edge is calculated along with the Euclidean distance. The number of edges remaining after the merging of the edges is assumed to be the number of sets of images. This value is used for the k-value for the k-image separation. The result of the detection limit is less than noise, which may affect the accuracy of the calculation. In addition to the k-k determination problem, other researchers have faced other issues. In [28] the authors addressed the problem of the implementation of kmethods or implementation methods (IM). Also, they compared eight widely used methods in different types of information.
To overcome the difficulty of obtaining a knee point index method used by Zhao [29] for BIC and the sum of squares in the study-based correlation coefficients has been proposed. A small amount is considered the most appropriate number of clusters.

Methodology
There are four key steps of our proposed system: (a) image acquisition for food images (b) extracted twelve colour features [30] and (c) k-means clustering (d) modified k-means clustering for connected food image segmentation. " Fig.1" shows the illustration of the flowchart for modifies k-means applied. The detailed description of the proposed method steps will be discussed in the following subsections.

Image acquisition
The first step in this process is to take a photo. It uses different types of food items in preparation. The program, using a smartphone with camera, stores 25 images in the Joint Photographic Scientists Group (JPEG) by default. Light adjustments do not require more than lighting indoor environment. There is no limit to the angle of acquisition of an angle to an additional corner of the dining table for the final purp precise information. The food is arranged on a round plate without any restrictions on the color of the plate.

Features for segmentation
In order to segment regions, each region is dealt separately. Classical k-means is applied on each region separately has to pass to it features. The selected features were mentioned in [30]. The k-means clustering algorithm is a split-based integration [31]. According to the algorithm, first select the k objects as the starting database, then the distance center must be calculated for each season between each cluster center and each object and should be assigned group. Thereafter, the ratings of all qualifications should be reviewed. This process should be repeated until the criterion function is change of the algorithm are shown in " Fig. 2".

4 Homogeneity test of k-means
Our aim in this paper is to modify the k-methods to fit the image classification. The most common problem in food classification is compiled from the two problems below: first, the standard way of organizing food items is to put them in the way they are linked. This can result in k-ends ending with local mining or poor assembly results because the data points are subdivided into other clusters (pixels can be partially separated from the nearest component). Second, there is no prior knowledge about the diet. To avoid such problems it is important to do two things [30]: First, the features should represent each pixel. Second, assuming that k is selected indiscriminately, the easiest way to verify that k is correct is to add to the algorithm a mathematical test called: homogeneity test. The role of this experiment is to ensure that the results of the cluster analysis are consistent to determine the optimal amount of food items. This is done by selecting a random number of samples in a fraction and calculating the difference in "Eq. 2" of those points. In this case, it is important to distinguish between two cases: the first case is when k is lower than the true value of food and the second case is k is higher than the true value of food. and k should be increased.When we are in the final case or the test gives a good decision, the results of the associated classification can lead to overlapping. To avoid the second case and save the first case k should be started from 0 and greater presented by the procedural process. The suspension index is taken when the homogeneity test gives the correct decision for the first time. In the meantime, the modified k methods should be discontinuous and the results of the linear combination should give the correct result for the separation. The Hk-coupled food separation algorithm is shown in " Fig. 3 ".

Fig.3. Pseudo code of Hk-means
In more details, to perform the homogeneity test random points of the region are generated. They are considered to be a testing cluster. The value of the variance is compared with pre-determined threshold (homogeneity threshold). In case the value is lower, the region is considered to be as homogenous and to consist of one food items. Otherwise, the region is considered to be non-homogenous and as combined of more than one food item.

Results and Discussion
To confirm the proposed method, As seen from " Fig. 4 "the number of groceries varies in sequence, three or four. Also, the composition of the food items is different indicating the different distribution of the points in each. Experiments were applied to a total of 25 images, without regard to the plate (which was removed with an active contour). Notably, the Hk-pathway classification provided the results of good classification with the ability to determine the optimal number of food items according to the homogeneity test. All of these tests were performed on a personal computer with Intel (R) Core (TM) memory and 4.00GB using Matlab R2018a.
The performance of the Hk algorithm has been compared with the argument [29]. Two types of experiments are performed.
• The first is responsible for generating an estimated value of k and comparing it to reality.
• Secondly it is responsible for determining the output time of the method and comparing it with the output from the bench. A total of 25 images were examined; the overall accuracy of the Hk-methods was 96%, but the accuracy of the bench was 60% for the estimated value of k.
In addition to validating the value of k, the extraction time is made up of 25 images and compared to the marking method. Fig.5 shows the results of the execution time. In " Fig. 5 ", the y-axis sees the time in seconds, and then the x-axis represents the images. Obviously our improved approach has received less competition time than the bench.

Conclusion and Future work
In this article a new image algorithm has been developed based on k-methods and named Hk-methods. This algorithm is effective in finding the correct number of clusters using a statistical test. This method was tested on a set of food items and provided an accuracy of 96% in predicting the number of food items and our improved method received less time limit than the measurement name. Future work is to incorporate this approach into an overall calorie-based diet plan to ensure full program independence.