Next Article in Journal
Review on Excess Noise Measurements of Resistors
Next Article in Special Issue
Illumination Temporal Fluctuation Suppression for Single-Pixel Imaging
Previous Article in Journal
An Investigation of All Fiber Free-Running Dual-Comb Spectroscopy
Previous Article in Special Issue
A Spatial-Motion-Segmentation Algorithm by Fusing EDPA and Motion Compensation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Superpixel-Based PSO Algorithms for Color Image Quantization

Department of Data Science and Engineering, Silesian University of Technology, Akademicka 16, 44-100 Gliwice, Poland
*
Author to whom correspondence should be addressed.
Sensors 2023, 23(3), 1108; https://doi.org/10.3390/s23031108
Submission received: 2 December 2022 / Revised: 13 January 2023 / Accepted: 14 January 2023 / Published: 18 January 2023
(This article belongs to the Special Issue Recent Advances in Imaging and Sensing 2022)

Abstract

:
Nature-inspired artificial intelligence algorithms have been applied to color image quantization (CIQ) for some time. Among these algorithms, the particle swarm optimization algorithm (PSO-CIQ) and its numerous modifications are important in CIQ. In this article, the usefulness of such a modification, labeled IDE-PSO-CIQ and additionally using the idea of individual difference evolution based on the emotional states of particles, is tested. The superiority of this algorithm over the PSO-CIQ algorithm was demonstrated using a set of quality indices based on pixels, patches, and superpixels. Furthermore, both algorithms studied were applied to superpixel versions of quantized images, creating color palettes in much less time. A heuristic method was proposed to select the number of superpixels, depending on the size of the palette. The effectiveness of the proposed algorithms was experimentally verified on a set of benchmark color images. The results obtained from the computational experiments indicate a multiple reduction in computation time for the superpixel methods while maintaining the high quality of the output quantized images, slightly inferior to that obtained with the pixel methods.

1. Introduction

Color image quantization (CIQ) is a transformation of a true color image (usually 8 bits for each RGB component) into an image with some colors, e.g., 8, 16, 32, 64, 128, and 256, which make up the color palette. Such a significant reduction in the number of colors in an image can enable faster, further image processing for such tasks as image compression [1], image segmentation [2], content-based image retrieval [3], etc. It is important to keep maximal similarity between the original image and the quantized image. Therefore, color image quantization can be considered a useful preprocessing operation.Although there are different CIQ methods, they consist of two main operations, which are the design of the color palette and the mapping of the pixels of the original image to the colors of the palette.
A few decades of development of the CIQ subject matter have resulted in several different approaches. The first methods can be called splitting methods. They split the solid color into smaller and smaller boxes, whose representatives (e.g., mean colors) are included in the final color palette. A good example of these is the classic method of median cut [4]. Splitting methods are fast, but quantized images often differ significantly from the original images. The second category of methods utilizes pixel clustering algorithms such as K-means (KM) [5] and fuzzy C-means (FCM) [6,7]. The clustering of pixels in a color image based on the unsupervised classification of millions of pixels compares their color similarities. The clustering methods used in CIQ provide high-quality quantized images, but their high computational complexity is the reason for the long quantization time. Additionally, their results depend on the initial conditions.
At the end of the last century, attempts were made to apply genetic [8] and evolutionary [9] algorithms for color quantization. Since 2005, work on applying swarm-based algorithms to color quantization has taken off. To solve this image preprocessing task, various metaheuristics have been used to mimic the behavior of groups of individuals, such as particles [10], ants [11], bacteria [12], frogs [13], fishes [14], bees [15], fireflies [16], wolves [17], etc. Recently, researchers have started using hybrid methods, that is, methods composed of several simpler algorithms, for color quantization. An example of this approach is the ant algorithm combined with the firefly algorithm [18] and a combination of the particle swarm optimization algorithm and the ant algorithm [19]. The goal of further work in the CIQ area will be methods that generate high-quality quantized images in a short time.
The aforementioned swarm and evolutionary algorithms belong to a large group of stochastic methods used in both optimization and simulation tasks [20]. Swarm intelligence algorithms were developed as a result of observations of nature in which different herds cooperate and exchange information between individuals. This leads to intelligent collective behavior that allows us to solve difficult problems. One of the first such algorithms was proposed in 1995 by J. Kennedy and R. Eberhart, the particle swarm optimization algorithm (PSO) [21]. In the PSO algorithm, each particle represents a candidate solution to a given optimization problem. The change in the position of a particle and, therefore, the change in the potential solution in each iteration, depends on the best known position of a given particle and the best known position of a particle from the entire swarm. One of the main advantages of swarm algorithms with respect to traditional optimization algorithms is that they start their operation from a population of potential solutions, rather than from a single point.
The PSO algorithm was first applied to the task of quantizing color images in 2005 [10]. The proposed PSO-CIQ algorithm combines the PSO algorithm with the K-means clustering algorithm. Before the values of the function are calculated, the particles are randomly selected and their positions are then refined by several iterations of the K-means algorithm.
For many years, PSO modifications have focused mainly on the selection of parameters (e.g., the number of particles in a swarm, acceleration coefficients, inertia weight, etc.), the modification of the neighborhood topology (e.g., grid, circle, star, and random), and the development of hybrid algorithms combining PSO with other metaheuristics (e.g., evolutionary algorithms). However, competition between particles was generally ignored. Among the many modifications of the recently developed PSO algorithm, we should note the version that also uses the evolution of individual differences (IDE-PSO) [22]. The authors of this algorithm introduced an evolutionary approach using individual differences. The algorithm assigns a coefficient called emotional status to each particle to determine individual differences, divides the whole swarm into three groups, and chooses an evolutionary method for each particle depending on its emotional status.
One way to reduce the CIQ time may be to preprocess the image by segmenting the image into superpixels and setting the color palette based on superpixels rather than pixels [23]. An image has fewer superpixels than pixels, so algorithms that operate on superpixels can run faster than pixel-based algorithms. The most popular method for generating superpixels is SLIC (simple linear iterative clustering) [24]. This algorithm uses the K-means method and classifies pixels based on color and their location. The distance between pixel colors is computed in the perceptually uniform CIELab color space. Each superpixel is assigned a mean color derived from the colors of its pixels. The number of superpixels in an image, their size, or their compactness depends on the type of superpixel generator. Of the characteristics listed here, color plays the most important role in the CIQ process, both in the pixel and superpixel versions. Splitting an image into superpixels, if performed quickly, can improve the efficiency of such image processing operations as CIQ or image segmentation. In the work [23], the authors proposed superpixel versions of three classic CIQ algorithms: median cut, K-means, and FCM. This approach allowed multiple decreases in computation time (15–30 times) with a minimal reduction in image quality.
In addition to the shorter execution time of CIQ operations, operation with limited computer resources was achieved. Image quality was evaluated using multiple indices (PSNR, FSIMc, DSCSI, HPSI, and SPSIM). An important parameter of superpixel CIQ algorithms is the number of superpixels into which the image was decomposed. It depends only on the number of quantization levels.
This study investigated the suitability of the IDE-PSO algorithm for CIQ tasks and the possibility of speeding up calculations due to the use of the superpixel approach (SP-IDE-PSO). The remainder of this paper is organized as follows. Section 2 presents the PSO-CIQ algorithm, its modification named IDE-PSO-CIQ, and our proposed superpixel versions of both methods. In Section 3, the experimental results and their discussion are shown. Finally, Section 4 concludes the article.

2. Materials and Methods

Swarm algorithms are a family of global optimization techniques inspired by the collective behavior of individuals (particles) that form a set of candidates to solve an optimization problem. A swarm of particles moves through the parameter space according to trajectories that depend on the best results of their own and those of their neighbors. Swarm particles perform rather simple tasks without central control. These particles actively seek the minimum of the objective function, work together in a topology-dependent manner, and swarm and memorize the previously obtained good results.

2.1. PSO-CIQ [10]

Applying the PSO algorithm to the CIQ task should define the space through which the particles will move. The first such application was carried out by Mahamed Omran in his work [10]. Each particle i-th X i can be described as
X i = { x i , 1 , x i , 2 , , x i , k , , x i , K } ,
where K—the number of colors in the color palette of the particle. The components of the particle are three-dimensional color vectors:
x i , k = [ R i , k , G i , k , B i , k ] .
Therefore, each particle in the swarm represents a different color palette, while the quality of each particle is evaluated on the basis of a quality index such as MSE. The pseudocode of the PSO-CIQ algorithm is shown below (Algorithm 1).
Algorithm 1 PSO-CIQ [10].
1:
Initialize each particle by choosing K colors from the RGB color space of the image and take them as initial p B e s t values.
2:
Calculate the values of the objective function f ( . ) for each particle and find the initial g B e s t value.
3:
while Stop condition of the algorithm do
4:
      for For each i-th particle do
5:
            Apply several iterations of the K-means algorithm with probability p k m e a n s
6:
            Update the particle velocity (Equation (3)) and position (Equation (4))
7:
            Calculate the value of the objective function f ( . ) for the particle
8:
            Update the personal best solution for the particle (Equation (5))
9:
            Update the best global solution (Equation (6))
10:
    end for
11:
end while
The initialization of the starting positions for each particle in the swarm (Step 1) is performed by randomly selecting K colors from the color space of the original image. Initially, these values are regarded as the personal best positions of the particles ( p B e s t ). For all particles, we find the global best solution, which minimizes the chosen objective function f ( . ) , in our case the MSE.
The main loop of the algorithm is then executed (Step 3). The algorithm is run and executed until a stop condition is met. The stop condition in this case is to reach the maximum number of iterations t m a x . At the beginning of each iteration (step 5), a random number is determined by a continuous uniform distribution of the interval [ 0 ; 1 ] . If this number has a value less than the value of the p k m e a n s parameter, then on the color palette represented by the particle in question there are several iterations of the K-means algorithm. This procedure reduces the image quantization error that results from the random start of the particle swarm. It also makes it possible to obtain much better final quantization results, both in terms of minimizing the quality index and improving the visual aspects of the image after quantization. In the next step, the particle velocity and position are updated:
V i t = w V i t 1 + c 1 r 1 ( p B e s t i t 1 X i t 1 ) + c 2 r 2 ( g B e s t t 1 X i t 1 ) ,
X i t = X i t 1 + V i t .
In Step 7, the value of the objective function for the i-th particle is determined. However, to determine the value of the objective function, one must first determine a new image from the color palette that the particle in question represents in a given iteration. To do this, calculate the distance between each pixel of the original image and each color in the color palette. Furthermore, the pixels are assigned to the colors of the palette for which the calculated distance has the lowest value. After the mapping of the image pixels to palette colors is performed, the MSE quality index of the image after quantization is determined. The value of this index is the value of the objective function of the particle. In the following steps (8,9), the personal and global best solutions are updated:
i f f ( X i t ) f ( p B e s t i t ) t h e n p B e s t i t = X i t ,
i f f ( X i t ) f ( g B e s t t ) t h e n g B e s t t = X i t .
The global best solution, and therefore the best color palette to date, is the solution represented by that particle for which the value of the objective function takes the lowest value.
After each time they are determined, a mechanism is used to prevent particles from “escaping” from the optimized space. In the case of CIQ problems, this space is the RGB color space with components in the range from 0 to 255. Thus, when a color from the palette represented by one of the particles takes a value outside this range, it is then limited to the limiting value of this range. A similar mechanism is also applied to the velocity of particles. In this case, the acceptable range of particle velocities is assumed to be [ V m a x ; V m a x ] .
The following values were assumed for the parameters of the PSO-CIQ algorithm:
  • N P —swarm size;
  • p k m e a n s = 0.1 —probability of applying the K-means algorithm;
  • t m a x = 50 —total number of iterations;
  • w m a x = 0.72 , w m i n = 0.4 —inertia weight coefficients;
  • c 1 = 1.49 —exploration coefficient;
  • c 2 = 1.49 —exploitation coefficient;
  • V m a x = 255 —maximum velocity value.
To strengthen the initial exploration phase and the final phase of exploitation, the following inertia weight coefficient was used, the value of which decreases linearly with successive iterations. Therefore, it was assumed that the initial value of the inertia weight coefficient was w m a x = 0.72 , while the final value of this coefficient decreased to w m i n = 0.4 . When using the K-means algorithm, 10 iterations were assumed.

2.2. IDE-PSO-CIQ

In 2017, a new modification of the PSO algorithm was proposed [22], which introduced an evolutionary mechanism into the algorithm that uses individual differences between particles. The IDE-PSO algorithm assigns to each particle a competition factor e X , called an emotional state, to quantify individual differences between particles. In this algorithm, based on the emotional state of each particle, the swarm is divided into three subgroups: weak, normal, and good. Depending on the particle’s affiliation to a given subgroup, its behavior changes, and thus its movement in the optimized multidimensional space (Algorithm 2).
Algorithm 2 IDE-PSO-CIQ.
1:
Initialize each particle by choosing K colors from the RGB color space of the image.
2:
Initialize each particle velocity at random and emotional states.
3:
Calculate the objective function for the first generation of particles.
4:
while Stop condition of the algorithm do
5:
      Group the particles with respect to their emotional state e X
6:
      for For each i-th particle do
7:
            while Stagnation Stag counter value reached do
8:
                 Update the position of the particle according to the mechanism corresponding to the its emotional state
9:
                  if If the position is within the limits of the search space then
10:
                     Then accept the new position and break the stagnation loop
11:
                else
12:
                     Reject the new position and increment the value of the stagnation counter
13:
                end if
14:
           end while
15:
           Apply several iterations of the K-means algorithm with probability pkmeans
16:
     end for
17:
     Evaluate the fitness of the current swarm
18:
     Update particles’ historical best position and the global best position
19:
     Update emotional status eXi of particles depending on the change in their change of fitness
20:
end while
The emotional state e X i of the i-th particle is initialized based on a random number r with a continuous uniform distribution in the interval [ 0.1 ; 0.1 ] (Equation (7)):
e X i 0 = r .
On the contrary, the emotional state in each iteration is determined by the value of the objective function of all particles. If the actual value of the objective function is better than the value of the previous iteration, then the emotional state of a particle grows by the value of Δ + (Equation (8)). Similarly, if the value of the objective function of a particle is less than the value of the previous iteration, its emotional state decreases by the value Δ (Equation (9)):
Δ + = ( f ( X i t 1 ) f ( X i t ) ) · ( f ( X i t ) f ( g b t ) ) ( f ( g w t ) f ( g b t ) ) 2 ,
Δ = ( f ( X i t ) f ( X i t 1 ) ) · ( f ( g w t ) f ( X i t ) ) ( f ( g w t ) f ( g b t ) ) 2 ,
where the symbols are defined as follows:
  • f ( . ) —the value of the objective function for a given solution;
  • X i t —the position of the i-th particle in a given iteration;
  • X i t 1 —the position of the i-th particle in the previous iteration;
  • g b t —the best global position among all particles in a given iteration;
  • g w t —the worst global position among all particles in a given iteration.
Furthermore, the closer a particle is to the best global solution, the smaller the value by which its emotional state changes.
In the IDE-PSO algorithm, three emotional states of the particles are defined: weak, normal, and good. Accordingly, the particles in each iteration are dynamically assigned to three subgroups based on the value of their emotional state. To split the particles into three groups, the particles are segregated according to their emotional state e X in such a way that the particle with the worst emotional state is the first in line. Two coefficients, m 1 and m 2 , whose values are in the range [ 0 ; 1 ] , are used as limits to assign particles to the three groups of the algorithm. Thus, we have a swarm of N P particles, and the allocation to the three emotional groups is performed as follows, where i n d i is the index of the i-th particle in the set of particles grouped by their emotional state:
  • i n d i m 1 × N P — particles with a weak emotional state;
  • m 1 × N P < i n d i m 2 × N P — particles with a normal emotional state;
  • m 2 × N P < i n d i — particles with a good emotional state.
Particles with a poor emotional state tend to move in the wrong direction or are more likely to stop at the local minimum of the optimized space. Therefore, the mechanism of moving weak particles leads the particles to abandon their current position and learn from the best particles in the swarm. The way in which weak particles change their position depends on a random number r with a continuous uniform distribution in the interval [ 0 ; 1 ] . A given particle is iterated relative to each j-th dimension. If the value of the random number r is less than the number 0.5, then the dimension j-th of the particle is set as the dimension j-th of the best global position (Equation (10)):
X i t ( j ) = g b t 1 ( j ) .
Alternatively, if the value of the random number r is greater than or equal to 0.5 , then the j-th dimension of the particle is taken as a random number from the interval belonging to the optimized space:
X i t ( j ) = l + ( u l ) r a n d [ 1 ; 1 ] ,
where l and u are the upper and lower limits of the optimized space dimension, respectively, and r a n d [ 1 ; 1 ] is a random number in the range [ 1 ; 1 ] .
Particles with a normal emotional state determine their new position in both, based on their own previous position and the best global position among the swarm. The formula to determine the velocity (Equation (12)) and position (Equation (13)) of these particles is the same as for the original version of the PSO algorithm:
V i t ( j ) = ω V i t 1 + c 1 r 1 ( p B e s t i t 1 X i t 1 ) + c 2 r 2 ( g B e s t t 1 X i t 1 ) ,
X i t = X i t 1 + V i t ,
where the symbols are defined as follows:
  • V i t —the velocity of the i-th particle in a given iteration;
  • V i t 1 —the velocity of the i-th particle in the previous iteration;
  • p B e s t i t 1 —the best known position of the i-th particle;
  • g B e s t t 1 —the best known position from the entire swarm;
  • c 1 , c 2 —the coefficient of exploration and exploitation;
  • r 1 , r 2 —random numbers with uniform continuous distribution from the interval [ 0 ; 1 ] ;
  • ω —the coefficient of inertia weight.
In a situation where a particle has a good emotional state, it stays confident because its value of the objective function has improved over the previous few iterations. Therefore, its next position is determined only on the basis of its past, regardless of the positions of other particles in the swarm. The mechanism for updating the velocity and position of these particles is presented as follows:
V i t ( j ) = ω V i t 1 ( j ) + 0.2 ω ( u l ) r a n d [ 1 ; 1 ] ,
X i t = X i t 1 + V i t .
The second term in Equation (14) is added to the previous value of the velocity of the particle to improve its exploration ability.
The IDE-PSO algorithm additionally uses the S t a g stagnation parameter. This parameter was introduced to prevent the particles from escaping from the optimized space. If a particle in a given iteration finds itself outside the search area, its newly determined position is abandoned, and a new position is recalculated. Each time a particle is found outside the search area, the counter of the stagnation parameter is incremented. If the value of the counter reaches the value of the S t a g parameter, then the particle remains in the same place.

2.3. Superpixel Versions of PSO-CIQ and IDE-PSO-CIQ Algorithms

The proposed superpixel CIQ methods, presented in Figure 1, use the original image as input to the superpixel generator (in our case, SLIC) and as input to the color pixel mapping. The generation of the color palette, the most complicated stage of the CIQ method, uses only the superpixel image. This proposed approach should significantly decrease the computation time and shorten the CIQ operation.
We used three algorithms to determine color palettes. To complete the operation, the color of each pixel within the original image is mapped to its nearest color from the palette. Introducing superpixels into the CIQ algorithm would decrease computational complexity while producing only a small reduce in image quality. We propose modified superpixel versions of the PSO algorithms: SP-PSO-CIQ and SP-IDE-PSO-CIQ. We compare these SP algorithms with their original pixel versions. We consider the dependence between the number of superpixels generated N S P and the quality of the final results. N S P should not be less than the number of colors k in the palette. To specify N S P , we propose the following empirical formula:
N S P = k + S P _ R a t i o · k ,
where S P _ R a t i o { 2 , 4 , 8 , 16 } .
The application of this formula to divide the image into superpixels is illustrated in Figure 2. Using a quantization level of k = 32, four images split into 96, 160, 288, and 544 superpixels were generated from the input image. With these tools, we can produce superpixel images, perform CIQ, and objectively evaluate image quality after quantization, allowing us to evaluate and assess superpixel CIQ methods.
The computational complexity of the PSO algorithm is linearly dependent on the size of the swarm and the number of input data. For the PSO-CIQ algorithm applied to digital images, the computational complexity is linearly dependent on the size of the swarm and the number of pixels in the image [10]. A simple analysis of the IDE-PSO-CIQ algorithm shows that its complexity is also O ( n ) . The main factor affecting the computation time is the number of pixels, and therefore reducing this number by introducing superpixels significantly affects the computation time, making it possible to obtain high values of computation rates.

2.4. Evaluation of Image Quality

Methods for evaluating image quality mainly refer to images with specific distortions. Comparatively, not much research has been conducted on the evaluation of image quality after CIQ-caused changes [25].
To verify image quality, we used ten different image quality indices, including classic mean squared error (MSE), peak signal-to-noise ratio (PSNR), and mean color error (DE). Each of above indices could be considered equally suitable for application to CIQ image changes. However, in recent research, indices have been proposed that are better correlated with the human perception.
For this work, we also chose the following modern quality indices: the color feature similarity index (FSIM) [26], the sparse feature fidelity index [27], the improved color-image-difference (ICID) index [28], the directional statistics color similarity index (DSCSI) [29], the Haar wavelet perceptual similarity index (HPSI) [30], and the mean deviation similarity index (MDSIS) [31]. The usability of the latter indices within the CIQ field has already been proven [32]. We also used the superpixel similarity (SPSIM) index proposed for application to superpixel segmentation results [33,34]. Most of these quality indices require maximizing values; only MSE, DE, ICID, and MDSIS are minimized.

3. Experiments, Results, and Discussion

All research was performed on a desktop computer with a CPU AMD Ryzen Threadripper 3960X at 3.80 GHz and 128 GB of RAM. The algorithms were implemented in the Matlab R2021b.

3.1. PSO-CIQ vs. IDE-PSO-CIQ

The paper [10] shows, for four benchmark color images: Lenna, Peppers, Jet, and Mandrill, that the PSO-CIQ algorithm generally achieved better results than the compared SOM and GCMA algorithms. Each benchmark image has a spatial resolution of 512 × 512 pixels—Figure 3. Table 1 of this paper has been supplemented with a column containing the results obtained for the proposed IDE-PSO-CIQ algorithm. In ten of the twelve cases studied, the IDE-PSO-CIQ algorithm achieved lower MSE values than PSO-CIQ.
In order not to be limited to the classic MSE index, we conducted similar studies on the same images for nine other pixel-based (PSNE, DE), patch-based (FSIM, SFF, ICID, DSCSI, HPSI, MDSIS), and superpixel-based (SPSIM) indices. The values of the indices are positively correlated with the image quality. The results of such a multi-index evaluation are included in Table 2. The bold values indicate the best of these for each image in the three palette sizes used. As in the previous experiment, the results of the IDE-PSO-CIQ algorithm dominated the PSO-CIQ results (94 of 108 comparisons in favor of the IDE version).

3.2. Superpixel Versions of Both Algorithms

The proposed superpixel versions of the PSO-CIQ and IDE-PSO-CIQ algorithms were tested on 24 test images from the Kodak test images (Figure 4) for 3 palette sizes (16, 64, and 256).
The average results obtained for both pixel and superpixel versions at different swarm sizes (5 and 20) are given in Table 3, Table 4 and Table 5 and the best ones are in bold. The quality of quantization is higher when a larger swarm size is used. From the tables discussed, it can be seen that the transition to superpixels results in a slight loss of quantized image quality. The use of a superpixel approach preserves the advantage of IDE-PSO-CIQ over PSO-CIQ. Generally, the IDE-PSO-CIQ algorithm achieved much better color quantization results in terms of the values of the quality indices. Two indices were chosen to evaluate the loss of quality in the quantized image: HPSI and SPSIM. For both algorithms tested (SP-PSO-CIQ and SP-IDE-PSO-CIQ), the percentage loss of the HPSI index values was in the range of 0.14–4.66% and for SPSIM it was in the range of 0.02–0.74%. Such changes can be considered minor changes in quality.
An important criterion for evaluating superpixel CIQ algorithms is the computation rate, defined as the ratio of the computation time of the tested algorithm in the pixel version to its computation time in the superpixel version. Figure 5 shows the computation rates of the tested superpixel versus pixel methods for small (NP = 5) and large (NP = 20) swarms. For example, for 16 colors with swarm size NP = 5, the average computation times (in seconds) for the pixel versions of the SP-PSO-CIQ and SP-IDE-PSO-CIQ algorithms were 2.91 and 5.68, respectively, and for the superpixel version they were 0.69 and 0.72, respectively. For the small swarm, computation rates ranging from 4.2 to 17.3 were obtained for the SP-PSO-CIQ algorithm and for the SP-IDE-PSO-CIQ algorithm, the computation rates ranged from 7.8 to 26. For the large swarm, computation rates ranged from 43.3 to 62.1 for the SP-PSO-CIQ algorithm, and for the SP-IDE-PSO-CIQ algorithm these computation rates ranged from 15.4 to 40.1. The above average computation rates were obtained on 24 images from the Kodak collection, with a 10-fold quantization performed for each image. For a small swarm, higher computation rates were achieved by the superpixel version of the IDE-PSO algorithm, and for a large swarm, higher computation rates were achieved by the super-pixel version of the PSO algorithm.

4. Conclusions

In this paper, two particle-swarm-optimization-based algorithms (PSO, IDE-PSO) are considered. Both algorithms have been applied to the important task of digital color image processing, i.e., in color image quantization (CIQ).This is the first time the IDE-PSO algorithm has been used in this field. Additionally, superpixel versions of both algorithms were considered, in which the number of superpixels used for adaptive palette generation depends on the palette size. The use of the superpixel approach is part of the novelty of the article. The experimental results show that the use of the IDE-PSO algorithm for CIQ yields better image quality than the classic PSO version, although over a longer time. The study was conducted on a large set of benchmark natural images. To evaluate the results obtained, ten quality indices (pixel-based, patch-based, and superpixel-based) were used, as well as a computation rate that determines the acceleration of calculations. Regardless of the swarm size, the advantage of the IDE-PSO-CIQ algorithms in both pixel and superpixel implementations is noticeable. The introduction of superpixel versions has made it possible to achieve a significant acceleration of PSO algorithm calculations with a small loss of image quality. The computing rates obtained are in the range of 4.2–62.1 with a quality loss of a few percent at most. In future research, we can improve the results using a different, more efficient superpixel decomposition method instead of the classic SLIC algorithm. This research will be important for all those who want a fast and high-quality color reduction method in computer vision tasks.

Author Contributions

Conceptualization, M.F. and H.P.; methodology, M.F. and D.P.; software, M.F. and D.P.; validation, M.F. and H.P.; investigation, M.F.; resources, M.F.; data curation, M.F.; writing—original draft preparation, M.F.; writing—review and editing, M.F.; visualization, M.F.; supervision, H.P. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Polish Ministry for Science and Education under internal grant 02/070/BK_22/0035 for the Institute of Automatic Control, Silesian University of Technology, Gliwice, Poland.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The Kodak image dataset is available at: http://r0k.us/graphics/kodak/ (accessed on 2 December 2022). Other data is not available.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

In this manuscript, the following abbreviations are used:
CIQColor Image Quantization
RGBRed, Green, Blue
KMK-Means
FCMFuzzy C-Means
SOMSelf-Organizing Map
GCMAGenetic C-Means Algorithm
PSOParticle Swarm Optimization
PSO-CIQParticle Swarm Optimization for CIQ
IDE-PSO-CIQIndividual Difference Evolution PSO for CIQ
SLICSimple Linear Iterative Clustering
CIELabLab color space defined by CIE
PSNRPeak Signal-to-Noise Ratio
FSIMFeature SIMilarity index (color version)
SFFSparse Feature Fidelity
MDSIMean Deviation Similarity Index
ICIDImproved Color Image Difference
DSCSIDirectional Statistics Color Similarity Index
HPSIHaar wavelet Perceptual Similarity index
SPSIMSuperPixel SIMilarity index
SP-PSO-CIQSuperPixel version of PSO-CIQ
SP-IDE-PSO-CIQSuperPixel version of IDE-PSO-CIQ

References

  1. Chou, C.H.; Liu, K.C. Color image compression using adaptive color quantization. In Proceedings of the 2004 International Conference on Image Processing, 2004. ICIP’04, Singapore, 24–27 October 2004; Volume 4, pp. 2331–2334. [Google Scholar]
  2. Deng, Y.; Manjunath, B.S. Unsupervised segmentation of color-texture regions in images and video. IEEE Trans. Pattern Anal. Mach. Intell. 2001, 23, 800–810. [Google Scholar] [CrossRef] [Green Version]
  3. Park, J.; An, Y.; Kim, P. Quantization of colors using median of pixels for color correlogram. In Proceedings of the International Conference on Technologies for E-Learning and Digital Entertainment, Hong Kong, China, 11–13 June 2007; pp. 723–729. [Google Scholar]
  4. Heckbert, P. Color image quantization for frame buffer display. ACM Siggraph Comput. Graph. 1982, 16, 297–307. [Google Scholar] [CrossRef] [Green Version]
  5. MacQueen, J. Some methods for classification and analysis of multivariate observations. In Proceedings of the 5th Berkeley Symposium on Mathematics, Statistics, and Probabilities, Berkeley, CA, USA, 1 January 1967; pp. 281–297. [Google Scholar]
  6. Dunn, J.C. A fuzzy relative of the ISODATA process and its use in detecting compact well-separated clusters. J. Cybern. 1973, 3, 32–57. [Google Scholar] [CrossRef]
  7. Bezdek, J.; Ehrlich, R.; Full, W. FCM: The fuzzy c-means clustering algorithm. Comput. Geosci. 1984, 10, 191–203. [Google Scholar] [CrossRef]
  8. Scheunders, P. A genetic c-means clustering algorithm applied to color image quantization. Pattern Recognit. 1997, 30, 859–866. [Google Scholar] [CrossRef]
  9. Freisleben, B.; Schrader, A. An evolutionary approach to color image quantization. In Proceedings of the 1997 IEEE International Conference on Evolutionary Computation (ICEC’97), Indianapolis, IN, USA, 13–16 April 1997; pp. 459–464. [Google Scholar]
  10. Omran, M.; Engelbrecht, A.; Salman, A. A color image quantization algorithm based on particle swarm optimization. Informatica 2005, 29, 261–269. [Google Scholar]
  11. Ghanbarian, A.; Kabir, E. An ant-based approach to color reduction. In Proceedings of the International Workshop on Ant Colony Optimization and Swarm Intelligence, Brussels, Belgium, 4–7 September 2006; pp. 364–371. [Google Scholar]
  12. Kaur, R.; Girdhar, A.; Gupta, S. Color image quantization based on bacteria foraging optimization. Int. J. Comput. Appl. 2011, 25, 33–42. [Google Scholar] [CrossRef]
  13. Pérez-Delgado, M.L. Color image quantization using the shuffled-frog leaping algorithm. Eng. Appl. Artif. Intell. 2019, 79, 142–158. [Google Scholar] [CrossRef]
  14. Yazdani, D.; Nabizadeh, H.; Mohamadzadeh Kosari, E.; Nadjaran Toosi, A. Color quantization using modified artificial fish swarm algorithm. In Proceedings of the Australasian Joint Conference on Artificial Intelligence, Perth, Australia, 5–8 December 2011; pp. 382–391. [Google Scholar]
  15. Kaur, R.; Gupta, V. Proposed method for color image quantization: Honey bee. Int. J. Comput. Sci. Commun. Eng. 2012, 1, 19–22. [Google Scholar]
  16. Jitpakdee, P.; Aimmanee, P.; Uyyanonvara, B. A hybrid approach for color image quantization using k-means and firefly algorithms. Int. J. Comput. Inf. Eng. 2013, 7, 600–607. [Google Scholar]
  17. Schaefer, G.; Agarwal, P.; Celebi, M. Effective colour reduction using grey wolf optimisation. In Proceedings of the European Congress on Computational Methods in Applied Sciences and Engineering, Rhodes Island, Greece, 15–17 June 2017; pp. 170–178. [Google Scholar]
  18. Pérez-Delgado, M.L. Artificial ants and fireflies can perform colour quantisation. Appl. Soft Comput. 2018, 73, 153–177. [Google Scholar] [CrossRef]
  19. Pérez-Delgado, M.L. Color quantization with particle swarm optimization and artificial ants. Soft Comput. 2020, 24, 4545–4573. [Google Scholar] [CrossRef]
  20. Szewczuk, M.; Konefał, A. Optimization of Image Quality in Digital Mammography with the Response of a Selenium Detector by Monte Carlo Simulation. Appl. Sci. 2023, 13, 171. [Google Scholar] [CrossRef]
  21. Kennedy, J.; Eberhart, R. Particle swarm optimization. In Proceedings of the IEEE International Conference on Neural Networks, Perth, WA, Australia, 27 November–1 December 1995; Volume IV, pp. 1942–1948. [Google Scholar]
  22. Gou, J.; Lei, Y.X.; Guo, W.P.; Wang, C.; Cai, Y.Q.; Luo, W. A novel improved particle swarm optimization algorithm based on individual difference evolution. Appl. Soft Comput. 2017, 57, 468–481. [Google Scholar] [CrossRef]
  23. Frackiewicz, M.; Palus, H. Efficient Color Quantization Using Superpixels. Sensors 2022, 22, 6043. [Google Scholar] [CrossRef] [PubMed]
  24. Achanta, R.; Shaji, A.; Smith, K.; Lucchi, A.; Fua, P.; Süsstrunk, S. SLIC superpixels compared to state-of-the-art superpixel methods. IEEE Trans. Pattern Anal. Mach. Intell. 2012, 34, 2274–2282. [Google Scholar] [CrossRef] [Green Version]
  25. Ramella, G. Evaluation of quality measures for color quantization. Multimed. Tools Appl. 2021, 80, 32975–33009. [Google Scholar] [CrossRef]
  26. Zhang, L.; Zhang, L.; Mou, X.; Zhang, D. FSIM: A feature similarity index for image quality assessment. IEEE Trans. Image Process. 2011, 20, 2378–2386. [Google Scholar] [CrossRef] [Green Version]
  27. Chang, H.W.; Yang, H.; Gan, Y.; Wang, M.H. Sparse feature fidelity for perceptual image quality assessment. IEEE Trans. Image Process. 2013, 22, 4007–4018. [Google Scholar] [CrossRef]
  28. Preiss, J.; Fernandes, F.; Urban, P. Color-image quality assessment: From prediction to optimization. IEEE Trans. Image Process. 2014, 23, 1366–1378. [Google Scholar] [CrossRef]
  29. Lee, D.; Plataniotis, K. Towards a full-reference quality assessment for color images using directional statistics. IEEE Trans. Image Process. 2015, 24, 3950–3965. [Google Scholar]
  30. Reisenhofer, R.; Bosse, S.; Kutyniok, G.; Wiegand, T. A Haar wavelet-based perceptual similarity index for image quality assessment. Signal Process. Image Commun. 2018, 61, 33–43. [Google Scholar] [CrossRef] [Green Version]
  31. Nafchi, H.; Shahkolaei, A.; Hedjam, R.; Cheriet, M. Mean deviation similarity index: Efficient and reliable full-reference image quality evaluator. IEEE Access 2016, 4, 5579–5590. [Google Scholar] [CrossRef]
  32. Frackiewicz, M.; Palus, H. K-Means color image quantization with deterministic initialization: New image quality metrics. In Proceedings of the International Conference Image Analysis and Recognition, Póvoa de Varzim, Portugal, 27–29 June 2018; pp. 56–61. [Google Scholar]
  33. Sun, W.; Liao, Q.; Xue, J.H.; Zhou, F. SPSIM: A superpixel-based similarity index for full-reference image quality assessment. IEEE Trans. Image Process. 2018, 27, 4232–4244. [Google Scholar] [CrossRef]
  34. Frackiewicz, M.; Szolc, G.; Palus, H. An improved SPSIM index for image quality assessment. Symmetry 2021, 13, 518. [Google Scholar] [CrossRef]
Figure 1. General idea of SP versions of the PSO-CIQ and IDE-PSO-CIQ methods.
Figure 1. General idea of SP versions of the PSO-CIQ and IDE-PSO-CIQ methods.
Sensors 23 01108 g001
Figure 2. Superpixel decomposition for image Peppers with K = 32 . (a) Image splitting into 96 superpixels ( N S P = 2 ). (b) Image splitting into 160 superpixels ( N S P = 4 ). (c) Image splitting into 288 superpixels ( N S P = 8 ). (d) Image splitting into 544 superpixels ( N S P = 16 ).
Figure 2. Superpixel decomposition for image Peppers with K = 32 . (a) Image splitting into 96 superpixels ( N S P = 2 ). (b) Image splitting into 160 superpixels ( N S P = 4 ). (c) Image splitting into 288 superpixels ( N S P = 8 ). (d) Image splitting into 544 superpixels ( N S P = 16 ).
Sensors 23 01108 g002
Figure 3. Selected benchmark color images.
Figure 3. Selected benchmark color images.
Sensors 23 01108 g003
Figure 4. Set of Kodak test images.
Figure 4. Set of Kodak test images.
Sensors 23 01108 g004
Figure 5. Computation rates of both superpixel CIQ methods for two swarm sizes. (a) N P = 5 . (b) N P = 20 .
Figure 5. Computation rates of both superpixel CIQ methods for two swarm sizes. (a) N P = 5 . (b) N P = 20 .
Sensors 23 01108 g005
Table 1. Comparison of MSE values between SOM, GCMA, PSO-CIQ, and IDE-PSO-CIQ.
Table 1. Comparison of MSE values between SOM, GCMA, PSO-CIQ, and IDE-PSO-CIQ.
ImageKSOMGCMAPSO-CIQIDE-PSO-CIQ
Lenna16235.6 ± 0.490332210.203 ± 1.487210.408 ± 1.228
32126.400 ± 1.200179119.167 ± 0.449118.478 ± 0.624
6474.700 ± 0.45811377.846 ± 16.13272.184 ± 0.256
Peppers16425.600 ± 13.162471399.63 ± 2.636372.813 ± 2.824
32244.500 ± 3.854263232.046 ± 2.295219.593 ± 1.122
64141.600 ± 0.917148137.322 ± 3.376130.338 ± 0.978
Jet16121.700 ± 0.458199122.867 ± 2.0837121.886 ± 1.968
3265.000 ± 0.0009671.564 ± 6.08963.769 ± 1.241
6438.100 ± 0.5395456.339 ± 11.1538.084 ± 0.909
Mandrill16629.000 ± 0.775606630.975 ± 2.059631.102 ± 2.236
32373.600 ± 0.490348375.933 ± 3.42373.592 ± 0.655
64234.000 ± 0.000213237.331 ± 2.015234.93 ± 0.372
Table 2. Multi-index quality evaluation: PSO-CIQ vs. IDE-PSO-CIQ.
Table 2. Multi-index quality evaluation: PSO-CIQ vs. IDE-PSO-CIQ.
ImageKAlg.PSNRDEFSIMSFFICIDDSCSIHPSIMDSISSPSIM
Lenna16PSO-CIQ29.676.1110.94800.98100.09060.76730.84230.30960.9620
IDE-PSO-CIQ29.656.1450.95020.98170.09010.76690.84730.30600.9631
32PSO-CIQ32.054.9150.97670.99000.04780.86190.92240.25250.9832
IDE-PSO-CIQ32.174.8530.97720.99040.04660.86650.92530.24920.9838
64PSO-CIQ34.104.0660.98900.99440.02790.91660.95680.20970.9920
IDE-PSO-CIQ34.323.9660.98990.99460.02620.92140.95870.20640.9926
Peppers16PSO-CIQ27.198.1090.91390.96880.14980.63370.74160.34720.9330
IDE-PSO-CIQ27.208.1110.91440.96920.14820.63520.74290.34640.9339
32PSO-CIQ29.446.5170.95530.98210.08380.76250.84940.28970.9666
IDE-PSO-CIQ29.496.4770.95570.98240.08270.76320.85010.28950.9668
64PSO-CIQ31.645.0930.97470.98860.05170.84140.90740.25380.9811
IDE-PSO-CIQ31.755.0240.97600.98910.04990.84640.90940.25020.9824
Jet16PSO-CIQ32.013.4980.96500.98600.04170.81570.87360.27430.9807
IDE-PSO-CIQ32.043.4860.96690.98600.03950.82080.87560.27040.9825
32PSO-CIQ34.682.9090.98370.99240.02450.88500.93250.22100.9915
IDE-PSO-CIQ34.862.8480.98470.99260.02250.88900.93500.21680.9929
64PSO-CIQ36.692.5500.99190.99510.01700.92190.95650.18480.9955
IDE-PSO-CIQ37.102.4270.99290.99530.01500.92640.96000.18000.9965
Mandrill16PSO-CIQ24.9111.3380.93760.96740.19150.65320.75050.33770.9526
IDE-PSO-CIQ24.9011.4450.93840.96660.19100.64990.75500.33630.9537
32PSO-CIQ27.159.3700.96700.97910.12510.76350.83860.28180.9744
IDE-PSO-CIQ27.189.3650.96690.97890.12510.75960.83800.28240.9743
64PSO-CIQ29.167.5870.98100.98730.07730.84390.89790.24210.9858
IDE-PSO-CIQ29.197.5720.98140.98730.07630.84420.89970.24150.9859
Table 3. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 16 ).
Table 3. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 16 ).
K = 16MSEPSNRDEFSIMSFFICIDDSCSIHPSIMDSISSPSIM
N P = 5
PSO-CIQ89.3628.995.9550.93850.97370.13830.70470.77400.31230.9582
IDE-PSO-CIQ83.1129.375.6450.94310.97600.12580.71960.78810.30470.9622
SP-PSO-CIQ108.0728.106.3700.92510.97030.15620.66910.74770.33240.9532
SP-IDE-PSO-CIQ93.0928.785.8950.93340.97450.13670.69810.77210.32030.9596
N P = 20
PSO-CIQ67.5630.185.3370.95020.97940.11560.74430.80900.29430.9663
IDE-PSO-CIQ67.3930.215.2990.95080.97950.11370.74620.81020.29340.9669
SP-PSO-CIQ93.2228.785.9110.93290.97450.13750.69700.77130.32090.9591
SP-IDE-PSO-CIQ91.8928.835.8450.93390.97470.13510.70040.77420.31960.9601
Table 4. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 64 ).
Table 4. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 64 ).
K = 64MSEPSNRDEFSIMSFFICIDDSCSIHPSIMDSISSPSIM
N P = 5
PSO-CIQ30.2433.723.6990.97890.99070.05400.86150.90880.23360.9861
IDE-PSO-CIQ22.1735.093.2300.98520.99280.03910.89240.93300.21170.9909
SP-PSO-CIQ34.9933.053.9040.97670.98950.05790.84940.90320.24380.9854
SP-IDE-PSO-CIQ28.2333.983.5930.98230.99160.04660.87720.92310.22600.9890
N P = 20
PSO-CIQ20.0835.513.2360.98770.99380.03840.90420.94030.20380.9917
IDE-PSO-CIQ19.0035.793.0940.98870.99390.03480.90860.94390.19890.9927
SP-PSO-CIQ28.6133.923.6640.98190.99170.04820.87620.92220.22690.9885
SP-IDE-PSO-CIQ27.3234.143.5420.98310.99190.04500.88150.92600.22320.9895
Table 5. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 256 ).
Table 5. Comparison of pixel and superpixel versions of PSO-CIQ and IDE-PSO-CIQ ( K = 256 ).
K = 256MSEPSNRDe76FSIMSFFICIDDSCSIHPSIMDSISSPSIM
N P = 5
PSO-CIQ11.1838.102.3880.99390.99650.01960.94280.96820.17160.9961
IDE-PSO-CIQ9.4338.872.1760.99500.99680.01560.95110.97320.16250.9971
SP-PSO-CIQ12.4737.572.4780.99360.99610.02030.94030.96690.17650.9959
SP-IDE-PSO-CIQ9.5638.702.2590.99550.99710.01560.95600.97480.16120.9972
N P = 20
PSO-CIQ7.1740.002.0940.99670.99780.01380.96470.98000.14900.9978
IDE-PSO-CIQ6.6040.411.9740.99710.99790.01200.96700.98160.14450.9982
SP-PSO-CIQ9.8638.552.3390.99540.99720.01660.95580.97440.16210.9970
SP-IDE-PSO-CIQ9.3138.822.2470.99570.99720.01530.95760.97570.15930.9973
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Frackiewicz, M.; Palus, H.; Prandzioch, D. Superpixel-Based PSO Algorithms for Color Image Quantization. Sensors 2023, 23, 1108. https://doi.org/10.3390/s23031108

AMA Style

Frackiewicz M, Palus H, Prandzioch D. Superpixel-Based PSO Algorithms for Color Image Quantization. Sensors. 2023; 23(3):1108. https://doi.org/10.3390/s23031108

Chicago/Turabian Style

Frackiewicz, Mariusz, Henryk Palus, and Daniel Prandzioch. 2023. "Superpixel-Based PSO Algorithms for Color Image Quantization" Sensors 23, no. 3: 1108. https://doi.org/10.3390/s23031108

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop