Content-Sensitive Superpixel Generation with Boundary Adjustment

: Superpixel segmentation has become a crucial tool in many image processing and computer vision applications. In this paper, a novel content-sensitive superpixel generation algorithm with boundary adjustment is proposed. First, the image local entropy was used to measure the amount of information in the image, and the amount of information was evenly distributed to each seed. It placed more seeds to achieve the lower under-segmentation in content-dense regions

Each superpixel is a simple single connected area with the regular shape.

2.
Superpixels should adhere well to the image boundaries and pixels inside the superpixels should have homologous characteristics.

3.
The density of superpixels should be adaptive to local image content.4.
The superpixels algorithms should be fast to compute and memory efficient.
The superpixel segmentation algorithms can be roughly divided into two categories: Graph-based methods and clustering-based methods.Graph-based methods treat each pixel as a vertex in the graph.The similarity between adjacent pixels is considered as the weight of the edge.The normalized cut (N-cut) algorithm [18] recursively partitions the pixel graph using contour and texture information in the image.Felzenszwalb and Huttenlocher [19] proposed a superpixel generation method based on the minimum spanning tree (FH).Moore et al. [20] generated superpixels (SL) by searching the minimum path from the horizontal and vertical directions.Veksler et al. [21] generated superpixels (Graph Cut) by half-overlapping square patches of the same size covered on the image.Liu et al. [22] presented a graph-based approach (ERS), which combines the entropy rate of a random walk with and a balancing function for superpixel segmentation.SEEDS [23] generates superpixels by iteratively modifying the initial approximate boundaries of superpixels according to the energy function.
The clustering-based methods define a distance measure to evaluate the similarity between pixels and generate superpixels by iteratively assigning pixels to the most similar seeds until some convergence criteria are reached.TurboPixels [24] is a geometric flow method (TP), which regularly places the seeds on images and grows the superpixels by level-set.This method can make the size of superpixels uniform, but it consumes more time than other superpixel methods.
Zeng et al. [25] proposed structure-sensitive superpixels (SSS) according to the geodesic distance computed from geometric flows.SSS can effectively describe the nonhomogenous features in images by the superpixel size.However, the computational cost of SSS is even higher than that of TP.
Achanta et al. [26] proposed an algorithm, simple linear iterative clustering (SLIC), to generate superpixels.SLIC uniformly places the initial cluster centers on the geometric center of the regular grids.By limiting the search range of the k-means algorithm, the computational complexity of the SLIC is greatly reduced.To further improve the performance of SLIC, Achanta and Susstrunk [27] proposed simple non-iterative clustering (SNIC) to compute superpixels with one iteration.
Liu et al. [28] proposed manifold SLIC (MSLIC), which expands SLIC to generate content-sensitive superpixels.MSLIC maps a five-dimensional image space to a two-dimensional manifold for computing restricted centroidal Voronoi tessellation under the Euclidean metric.As an improvement of MSLIC, the authors proposed intrinsic manifold SLIC [29] (IMSLIC) to compute a centroidal Voronoi tessellation under the geodesic distance instead of Euclidean distance on the image manifold.
Shen et al. [30] presented the lazy random walk (LRW) method to evaluate the probabilities between a seed and its neighbor pixels.The authors [31] also proposed a real-time superpixel segmentation method (DBSCAN) to apply density-based spatial clustering.Small initial superpixels are further merged with adjacent superpixels to ensure connected superpixels.
Li and Chen [32] proposed the linear spectral clustering (LSC) to generate superpixels based on simple k-means clustering.The algorithm maps a five-dimensional color space into a ten-dimensional space, resulting in superpixels with high boundary adherence.
All the above clustering-based methods usually consist of two steps: (1) Regular initialization of seeds to generate superpixel, and (2) update seeds to the center of mass.The results of this algorithm depend on the initial position of seeds, and the seed regular initialization ignores the content sensitivity.To address this issue, we propose a novel superpixel segmentation algorithm, which adopts the image local entropy and the boundary adjustment strategy to generate superpixels.In summary, the contribution of this paper includes the following three respects: 1.
The seeds initialized by most cluster-based superpixel algorithms are spatially uniform.Our method introduces image entropy at seeds sampling, which aims at generating content-sensitive superpixels to improve the accuracy of superpixel segmentation.The image local entropy can well measure the content sensitivity of the image and can initialize the seeds at a lower computational cost.

2.
We used boundary adjustment to optimize superpixels.Adaptive boundary adjustment can generate regular superpixels in sparse content areas and superpixels with good boundary adherence in dense content areas, and the boundary adjustment can quickly converge.
Compared with other five methods, the algorithm achieved better segmentation accuracy while ensuring superpixel compactness.
The rest of the paper is organized as follows.The Section 2 introduces our method and analyzes the parameters in detail.The experimental results, compared with the five representative methods, are shown in Section 3. Experimental results are discussed in Section 4. In Section 5, we show the foreground segmentation performance of the superpixel algorithm proposed in contour closure.Finally, a brief summary is made in Section 6.

Materials and Methods
This paper develops a novel method for generating content-sensitive superpixels, which improves the performance of segmentation algorithms.The proposed algorithm has three phases.The first phase is seed sampling for adaptive image content.The second phase is clustering superpixels based on the minimum spanning tree algorithm.The third phase is the boundary adjustment phase, in which the distance measure of adaptive weights is adopted to improve the segmentation quality.

Seed Sampling Strategy
Any natural image contains a lot of uneven image information.The change in the local color intensity of the image reflects the change in the amount of local information.Therefore, it is but natural to place more seeds in content-dense regions of the image and to place fewer seeds in content-sparse regions of the image.However, the uniformity of seeds is also strongly important for the compactness of superpixels.Then, the proposed seeds distribution strategy based on image local entropy achieved a balance between the content sensitivity and uniformity of seeds.The heterogeneity of each pixel was captured using Normalized Shannon Entropy.The entropy operator calculates the entropy of the pixel value in the neighbor center.Let the pixel gray values in the center and the N neighbor pixels be a 0 , a 1 , a 2 , . . ., a N , respectively.The entropy operator is given in Table 1.P i log P i /log(N + 1) The entropy H was normalized so that H ∈ [0, 1].For color images in the CIELAB color space c = l a b T , the image local entropy is defined as where Both brightness information and tone information were used to measure the local entropy carried by natural color images.Therefore, when the brightness or the color tone of the region changed greatly, the entropy value of the color image was small.The part of the image should contain more information when the color intensity of the part of the image changes drastically, and vice versa.For neighborhood center i, the local information of each pixel I(i) is defined as where ω and γ are scaling parameters.We outline seed sampling strategy in Algorithm 1. Different from the placement method of simple regular grids seeds [26] and two-level quad-tree split-up seeds [25], the proposed approach considered the local information of the image in the process of placing seeds.In order to make each superpixel contain an approximate amount of image information, the information interval was s = n i=1 I(i)/k, where n is the number of pixels in the image and k is the desired number of superpixels.The images were scanned from left to right and from top to bottom, and the pixels were added that were four-or eight-connected to the currently growing region.When the scanned pixels reached the information interval, the seed was placed.For an initial superpixel S i , its position center

Minimum Spanning Tree Clustering
An image can be converted to an undirected graph G = (V, E), whose pixels in the image v ∈ V are the vertices and the value of each edge e ij = v i , v j evaluates the similarity between the two vertices e ∈ E ⊆ V × V. Let k be the number of superpixels to be divided, the superpixel segmentation task is broken up the undirected graph G into k disjoint subgraphs G = (V , E ), where V ⊆ V and E ⊆ E.
The proposed algorithm is a kind of bottom-up pixel aggregation method, which grows regions based on the Prim method [34].The Prim algorithm is a greedy algorithm that finds the minimum spanning tree for a weighted undirected graph.Suppose a graph has n vertices, and the goal is to aggregate the vertices into a forest with k trees.Starting from the initial seeds, the algorithm adds the least cost connection from the tree to the vertex in each step.Similar to SLIC [26], a distance measure was adopted in five-dimensional space.In the spatial space x = x y T and CIELAB color space c = l a b T , the distance of two vertices v 1 and v 2 is defined as (5) where N x is a normalization parameter.For an image of n pixels, the value of N x is set to be √ n/k.The value of λ is set by the user.λ weighs the relative importance of the color distance term and spatial distance term.The larger the λ value is, the more regular the generated superpixels are.The smaller the λ value is, the boundary adherence better the generated superpixels are.
The Prim algorithm only considers the distance between two vertices on the tree border during the aggregation process.This metric is extremely sensitive to noise.The average attributes of the tree are used to calculate the distance, which not only simplifies the calculation of the shortest path distance in the neighbor, but also improves the robustness of the Prim algorithm.After running the Prim algorithm, k trees representing k superpixels are generated.For a superpixel S i , its average attribute The average attribute replaces the seed to calculate the distance.Figure 1 illustrates this aggregation process of superpixels.The process of minimum spanning tree clustering is summarized in Algorithm 2.
Update the centroid C i using Equation ( 6) for Each connected neighbor v j of v i do Calculated distance of v j and v i using Equation ( 5)

Boundary Adjustment
The preliminary segmentation results were formed at one time and further optimization was required.In Figure 2, the shape of the superpixel was not regular enough, especially in the content-sparse region.There were several under-segmentation errors in the area pointed by the red arrow in the image.It can be seen that boundary adjustment significantly improved the compactness and boundary adherence of superpixels.The boundary pixels of the initial superpixels were allocated to obtain better compactness and boundary adherence.Among pixels connected to S i , the pixels that do not belong to S i are boundary pixels.For each boundary pixel, calculate the distance between the boundary pixel and the adjacent superpixel, and assign the boundary pixel to the superpixel which is nearest to it.Boundary adjustment is an iterative process.The iteration is terminated when the set number of iterations is reached.
In the distance Equation ( 5), the color distance term affects the adherence of superpixels boundary, and spatial distance term affects the compactness of superpixels.To enhance the content sensitivity of superpixels, we define the new distance measurement as follows: When the value I(i) is higher, the color distance is more considered.When the value I(i) is lower, the spatial distances should be more considered.Boundary adjustment does not guarantee the superpixel connectivity.In the procedure, a superpixel may be split into several unconnected sub-superpixels.Connectivity is taken into account of the procedure of boundary adjustment and additional steps are not required.For too small sub-superpixels, they will merge with the nearest superpixel.The pseudo code of boundary adjustment is presented Algorithm 3.

Algorithm 3. Boundary adjustment
Input: Initial Superpixel label map L and the maximum number of iterations Maxiter Output: Optimized Superpixel label map L While iter < Maxiter do for each superpixel S i do for each boundary vertex v i do for Each connected neighbor v j of v i that are not in S i do Get the superpixel S j which v j belongs to Compute D (v j , C j ) and D (v j , C i ) using Equation ( 7) Update C i and C j using Equation ( 6)

Update the boundary vertices end if end for end for end for end while
For an image with n pixels, it is obvious that the complexity of the image local entropy and the seed sampling strategy are О(n).In the minimum spanning tree clustering phase, the number of pixels in the priority queue is much smaller than n.Thereby, the impact of priority queues on computational complexity is not very obvious.In the boundary adjustment stage, the computational cost in each iteration is О(n B ), in which n B is the number of boundary pixels.In practice, n B n.In the comprehensive analysis, the proposed algorithm is of linear complexity О(n).

Datasets and Performance Metrics
We adopted the commonly used evaluation metrics in the literature of superpixel segmentation to evaluate superpixel segmentation algorithms, including boundary recall (BR), achievable segmentation accuracy (ASA), and under-segmentation error (USE).The BSDS 500 [33] consisted of 500 images with manually labeled ground truth segmentations.In the following experiments, the methods were evaluated using the average performance metrics of five hundred images in the BSDS 500 [33].
Boundary recall (BR) measures the fraction of the ground truth boundary identifications.A high BR represents the better boundary adherence with respect to the ground truth boundaries.Given a ground truth boundary sets B(g) and the superpixel boundary sets B(s), then BR is defined as: Let FN (B(g), B(s)) and TP (B(g), B(s)) be the number of false negative and true positive boundary pixels.B(s) is matched to B(g) within a local neighbor with size (2r + 1) × (2r + 1).In practice, r is set to 1.
Achievable segmentation accuracy (ASA) computes the upper bound of accuracy using superpixels as preprocessing step.Denote a ground truth segmentation of an image as {G i |i = 1, 2, • • • , M} and a superpixel segmentation as {S l |l = 1, 2, • • • , K}.The ASA metric is defined as follows: where |.| is the number of a superpixel in pixel.In general, a high ASA demonstrates that superpixels match the objects well in the image.Under-segmentation error (USE) measures the "leakage" of superpixels from the ground truth boundaries, which is calculated by: where n is the total number of pixels in the image.Each superpixel was assigned to the ground truth segments with the largest overlap, and only the "leakage" with respect to other ground truth segments was considered.Therefore, USE implicitly also measures boundary adherence.A lower USE refers to that superpixels overlap with a ground truth segmentation more accurately.

Parameter Selection
In the proposed method, γ, ω, λ, and Maxiter should be set in advance.The following experiments use various values to investigate the parameters.
The measure of image information contains two parameters, γ and ω. γ is used to adjust the uniformity and content sensitivity of the seeds.As shown in Figure 3, with the increasing values of γ, the value of performance metrics changes significantly because small γ values imply the seeds are too sensitive to the image content and concentrated in complex areas while ignoring other areas.When γ becomes too large, the distribution of seeds tends to regular grid seeds, and the content sensitivity is ignored.ω is used to adjust the proportion of the color term in Equation (7).In practice, we truly use their product, p = ω • γ.Approximately, the values of I(i) fall in the interval [0, p].As shown in Figure 4, when p increases, more detailed information is considered and the resulting superpixels are more irregular.λ represents the weight parameters of the distance measure in the stage of minimum spanning tree clustering.Particularly, when λ→∞, the generated superpixels are regularly grid only related to the position of the initial seeds.When λ = 0, the pixels with similar colors are clustered to generate irregular superpixels.The trend is shown in Figure 5. Figure 6 shows the average values of BR, ASA, and USE on the BSDS 500 for different λ values when K = 400.Overall, the performance metrics becomes worse as the value of λ increases.The number of iterations Maxiter can balance time cost and performance.The metrics with Maxiter are shown in Figure 7.It is easy to find that our algorithm can quickly converge after two iterations.More iterations will only increase time consumption.Also shown in Figure 2, the superpixels became more compact after iterations.From the discussion above, we select γ = 6 and Maxiter = 3, where achieve the best performance.Considering the accuracy and compactness of superpixels, we empirically select λ = 20 and p = 3.

Results
The proposed algorithm was implemented in C++ and tested on a PC with an Intel i5-8300H CPU (2.30 GHz) and 8GB RAM.The performance of the proposed algorithm was compared with the five representative superpixel generation algorithms, including SLIC [26], SNIC [27], ERS [22], LSC [32], and FH [19].We used the implementations available online for all other methods.To ensure segmentation performance, all algorithms were run on the recommended parameters.The comparison experiment results on BSDS 500 [33] are shown in Figure 8.As a preprocessing step for image processing, the time cost was also an important indicator.In Figure 8d, we also compared the efficiency in the average running time per image.Table 2 presents the mean and standard deviation performance metrics at k = 400.A visual comparison is displayed in Figure 9.A good initialization is essential for superpixel algorithms.In Section 2.1, we propose a seed sampling strategy different from regular grid initialization, which introduces image entropy into seed sampling strategy to optimize the content sensitivity of the seed.Furthermore, the content initialization compares with regular initialization in the proposed method on the entire BSDS 500 dataset.The results under the three metrics (i.e., USE, BR, and ASA) are reported in Figure 10, which shows that our sampling strategy is better than regular grid initialization.A good initialization is essential for superpixel algorithms.In Section 2.1, we propose a seed sampling strategy different from regular grid initialization, which introduces image entropy into seed sampling strategy to optimize the content sensitivity of the seed.Furthermore, the content initialization compares with regular initialization in the proposed method on the entire BSDS 500 dataset.The results under the three metrics (i.e., USE, BR, and ASA) are reported in Figure 10, which shows that our sampling strategy is better than regular grid initialization.

Discussion
Referring to the plots in Figure 8, our method is superior to the other five methods in terms of ASA and USE.The LSC, ERS, and our method exhibit high performance on BR.However, our approach is more competitive at a lower set number of superpixels.As a preprocessing step, generating a lower number of high-quality superpixels is more helpful for subsequent tasks.From Figure 8 and Table 2, it can be seen that the proposed method is comparable to the other five representative methods in terms of boundary adherence.
Figure 9 shows the visual results of superpixel segmentation using these algorithms.Enlarge the local segmentation results for detailed inspection.Visually, our method had the most satisfactory segmentation results for different types of images.SLIC, SNIC, and our method showed the best compactness.However, compared with the proposed algorithm, SLIC and SNIC had weaker boundary adherence.The boundary adherence of ERS was very competitive, but the compactness of ERS was not satisfactory.LSC produced competitive results and performed well in compactness and boundary adherence.LSC introduces global information to generate superpixels, which makes it requires 20 iterations.From Figure 8d, LSC took longer to run than our method.In addition, our method can exceed the performance of LSC by adjusting parameters, but it sacrifices compactness.Superpixels generated by FH and the proposed method exhibited content sensitivity.Due to the lack of compactness constraints, the superpixels produced by FH were extremely irregular and under-segmented in content-rich areas.The results show that the algorithm achieves good boundary adherence while ensuring good compactness.

Application to Image Contour Closure
We investigated the effect of segmentation using different superpixels in image contour closure applications.Superpixel is a preprocessing step to reduce the complexity of subsequent image tasks.Levinshtein et al. [6] proposed an energy framework to search for a subset of superpixels to obtain the contour of strong edge support in an image.The energy framework proposed by Levinshtein et al. was used to compare six superpixel algorithms.The energy framework was applied to the Weizmann Segmentation Evaluation Database (WSED) [35], which consists of 100 images with human-annotated ground truth segmentations for each image.The average F-measure, precision, and recall are summarized in Table 3.

Conclusions
In this paper, we present a content-sensitive superpixel generation method with boundary adjustment, which generates compact superpixels that are adapted to image content.Owing to the uneven distribution of seeds, compared to other seed-based methods, the proposed algorithm is more sensitive to the content of the image.The approach tends to generate relatively small and irregular superpixels in complex regions for better boundary adherence, and generates relatively large regular superpixels in flat regions to improve computational efficiency.Taking advantage of boundary adjustment, the proposed algorithm provides results can adapt well to structure changes in natural images.We compared the proposed algorithm with five representative methods on the BSDS 500 dataset.The experimental results demonstrate that superpixels generated by the proposed method outperform the five superpixel algorithms in terms of USE, BR, and ASA.In the future, we will further research the algorithm in a noisy environment.In addition, we plan to apply this approach to applications that require content-sensitive superpixel algorithms.

Algorithm 2 .
Minimum Spanning Tree Clustering Input: An image I of n pixels, k initial locations x i generated in Algorithm 1 and the weight parameter λ Output: Initial Superpixel label map L Initialize L[:] ← −1 Initialize C i = x i c i by extracting the features of the initial locations x i for each centroid

Figure 1 .
Figure 1.Illustration of the aggregation process of superpixels.The vertices represent pixels and the edges represent similarities.(a)The vertex 15 is the nearest neighbor of the tree (red vertex 11), (b) the tree aggregates the nearest neighbor, (c) update the average attribute of the tree, (d) expand the search scope of the tree and find the next nearest neighbor(vertex 9).

Figure 3 .
Figure 3.The performance metrics of our approach with different γ values.

Figure 4 .
Figure 4. Superpixel segmentation results with different p values.

Figure 6 .
Figure 6.The performance metrics of our approach with different λ values at k = 400.

Figure 7 .
Figure 7.The performance metrics of our approach for different Maxiter values.

16 Figure 9 .
Figure 9. Visual comparison of superpixel segmentation results using different algorithms.

Figure 10 .
Figure 10.The metrics value comparison of our seed sampling strategy and grid initializations.

Figure 9 .
Figure 9. Visual comparison of superpixel segmentation results using different algorithms.

Figure 10 .
Figure 10.The metrics value comparison of our seed sampling strategy and grid initializations.
Figure 11 also shows the qualitative results of the four examples.Both quantitative and qualitative results show that the proposed method has good foreground segmentation performance.

Figure 11 .
Figure 11.Visual comparison of contour closure results on four examples in Weizmann Segmentation Evaluation Database (WSED).The superpixel boundaries are shown in green, and the closure contours are shown in red.

Table 2 .
Performance metrics of different superpixel segmentation algorithms at k = 400.

Table 3 .
Performance metrics of the framework on WSED.