Keywords

1 Introduction

Colour images usually use 24 bits per pixel, which results in \(2^{24}\) distinct colours. However, humans can recognise only up to a thousand different colours. Therefore, reducing the number of colours may not affect perception while leading to reduced complexity and resources. Colour quantisation is a process to reduce the number of distinct colours in an image and represent image colours by a colour palette comprising a small number of colours (often between 8 and 256)  [1]. Colour quantisation is essential in some applications such as video conferencing and transmission through limited bandwidth channels  [13, 14], while also providing a compression method that simplifies the feature space  [5].

The primary goal of colour quantisation algorithms is to yield a good palette. If the values of the palette are not properly selected, the resulting image will show more discrepancies compared to the original image and thus lower image quality. Therefore, choosing appropriate entries in the palette is important, it is however also known as an NP-hard problem, making colour quantisation a challenging task.

In the literature, various colour quantisation algorithms have been proposed. A relatively simple method is the popularity algorithm  [4] which chooses the colours that are represented most often in the image. In median cut quantisation  [4], the colour space is divided into sub-spaces in an iterative process, while in  [3], the colour space is represented as an octree whose sub-branches combine to form the pallete. Self-organising Kohonen neural networks have also been proposed  [2], as have a number of soft computing methods  [8] such as simulated annealing  [10], fuzzy c-means  [11], rough c-means  [12], and fuzzy-rough c-means  [9].

Human mental search (HMS)  [7] is a recent population-based metaheuristic algorithm inspired by the exploration strategies in the bid space of online auctions. HMS has three main operators: (1) mental search, which explores the vicinity of each solution based on Levy flight, (2) grouping, which partitions the search space using a clustering algorithm, and (3) moving bids towards promising regions.

In this paper, we propose a novel method for colour quantisation based on the HMS algorithm. We formulate the colour quantisation problem as an optimisation problem and employ HMS to identify an optimal colour palette. Experimental results obtained on a benchmark image set show that our proposed approach is capable of outperforming both conventional and other soft computing-based colour quantisation methods.

The remainder of this paper is organised as follows. Section 2 introduces the HMS algorithm, while our proposed algorithm is presented in Sect. 3. Section 4 gives experimental results and discusses the performance of the proposed algorithm against other approaches. Finally, Sect. 5 concludes the paper.

2 Human Mental Search

Human mental search (HMS) is a recent population-based metaheuristic algorithm inspired by exploring strategies in the bid space of online auctions. Each candidate solution in HMS is called a bid, and the algorithm is based on three main operators, mental search, grouping, and movement towards a promising region. In the following, these operators are described in more detail, while Algorithm 1 lists the pseudo-code of the HMS algorithm.

figure a

2.1 Mental Search

Mental search explores the vicinity of a candidate solution using Levy flight. Levy flight is a type of random walk that generates random movements based on a Levy distribution. In Levy flight, there are some small movements and then a long jump which increases both exploration (due to the long jumps) and exploitation (due to the small movements) simultaneously. Mental search generates some new solutions according to

$$\begin{aligned} NS = bid + S , \end{aligned}$$
(1)

with

$$\begin{aligned} S = (2-iter(2/MaxIter)) 0.01 \frac{u}{v^{1/\beta } } (x^{i} -x^*) , \end{aligned}$$
(2)

where \(x^*\) is the best position found so far, u and v are two random numbers with normal distributions, MaxIter is the maximum number of iterations, iter shows the current iteration, and \(\beta \) is a random number, while \(\oplus \) denotes element-wise multiplication. \((2-iter(2/MaxIter))\) is a descending factor, starting at a point near 2 and ending towards 0, and thus considers a larger vicinity of a solution at the beginning (exploration) and smaller vicinities at the end of the algorithm (exploitation).

2.2 Grouping

In this step, the solutions are grouped using a clustering algorithm. For this, we use the k-means algorithm to cluster the population. Then, the mean cost of each cluster is calculated and the cluster with the lowest mean cost value selected as a promising region.

2.3 Movement Towards Promising Region

In this step, candidate solutions move towards the best solution in the promising region, governed by

$$\begin{aligned} x_{n}^{t+1} = x_{n}^{t} +C(r \times winner_{n}^{t} - x_{n}^{t} ) , \end{aligned}$$
(3)

where \(x_{n}^{t+1}\) is the n-th bid element at iteration \(t+1\), \(winner_{n}^{t}\) is the n-th element of the best bid in the winner group, t is the current iteration, C is a constant, and r is in is a random number drawn from a uniform distribution between 0 and 1.

3 Human Mental Search for Colour Quantisation

In this paper, we apply an improved HMS algorithm to the colour quantisation problem. For this, two issues need to be determined: (1) representation and (2) objective function.

In our approach, the representation is an array which encodes the colours of the colour palette. The length of the array is to \(N_{var}=3k\) where k is the number of colours in the palette and we store the RGB values of each colour. The objective function is chosen to minimise the mean squared error (MSE) between the original and quanitsed image

$$\begin{aligned} f(I_{o},I_{q})=\frac{1}{3nm}&(\,\sum _{i=1}^{n}\sum _{j=1}^{m}[(R_{o}(i,j)-R_{q}(i,j))^2] \nonumber \\+ & {} \sum _{i=1}^{n}\sum _{j=1}^{m}[(G_{o}(i,j)-G_{q}(i,j))^2] \nonumber \\+ & {} \sum _{i=1}^{n}\sum _{j=1}^{m}[(B_{o}(i,j)-B_{q}(i,j))^2]) , \end{aligned}$$
(4)

where m and n are the dimensions of the image, and R(i, j), G(i, j), and B(i, j) are the red, green, and blue pixel values at location (i, j) while the subscripts o and q denote the original and quantised image.

In our approach, we improve the human mental search based on the personal experience of each candidate solution. To this end, the update equation, Eq. (3), is changed to

$$\begin{aligned} x_{n}^{t+1} = bid_{n}^{t} +C_{1}r(winner_{n}^{t} - x_{n}^{t})+ C_{2}r(pbest_{n}^{t} - x_{n}^{t}) , \end{aligned}$$
(5)

where pbest is the position of the best solution found so far by the n-th candidate, and \(C_1\) and \(C_2\) are constants.

4 Experimental Results

To verify the performance of the proposed method, we have used six commonly employed benchmark images shown in Fig. 1, namely Lenna, Peppers, Mandrill, Sailboat, Airplane, and Pool. In all experiments, the number of colours in the palette is set to 16  [8] and we set \(M_l=2\), \(M_h=10\), K (the number of clusters during grouping) to 5, \(L=0.3\), \(U=1.99\), and \(c_1=c_2=1.5\). HMS is run with a population size of 50 for 500 iterations.

Fig. 1.
figure 1

Test images: Lenna, Peppers, Mandrill, Sailboat, Pool, and Airplane.

We compare our proposed algorithm to four conventional quantisation algorithms namely popularity algorithm  [4], median cut  [4], octree quantisation  [3], and Neuquant  [2], and seven soft computing-based approaches including SWASA  [10], fuzzy c-means (FCM)  [11], random sampling FCM (RSFCM)  [11], Enhanced FCM (EnFCM)  [11], anisotropic mean shift based FCM (AMSFCM)  [11], rough c-means (RCM)  [12], and fuzzy-rough c-means (FRCM)  [9].

As evaluation measure we use the peak signal-to-noise-ratio (PSNR), which is the most commonly employed metric to evaluate colour quantisation algorithms and is defined as

$$\begin{aligned} PSNR(I_{o}, I_{q})=10\log _{10}\frac{255^{2}}{MSE(I_{o}, I_{q})} , \end{aligned}$$
(6)

where MSE is the mean squared error calculated as in Eq. (4).

Table 1 compares the results obtained for our proposed algorithm against the other evaluated techniques. It can be observed that the octree and Neuquant algorithms outperform the popularity and median cut approaches. Furthermore, it is clear that the soft computing-based colour quantisation algorithms outperform octree and Neuquant confirming that methods based on soft computing techniques are effective tools for colour quantisation  [8].

Table 1. Comparison of proposed algorithm with other colour quantisation algorithms. Results are given in terms of PSNR [dB].
Table 2. Algorithm ranking

Also apparent from Table 1 is that our proposed HMS colour quantisation algorithm yields excellent results and is convincingly shown to outperform all other algorithms giving the best image quality for all images except Pool, for which FRCM and EnFCM perform slightly better.

We also perform a ranking analysis where, as shown in Table 2, we rank all algorithms on each image based on the PSNR results. We then average the ranks for each algorithm to identify an overall ranking. From Table 2, it is clear not only that our proposed algorithm ranks first but also that it yields a significantly lower average rank of 1.33 compared to all other algorithms with FRCM second with an average rank of 2.92. FCM ranks third while, as expected, the conventional quantisation algorithms are the lowest ranked techniques.

In Figs. 2, 3 and 4, we show, as examples, the quantisation results from several algorithms on three of the images, namely Sailboat, Pool and Airplane. For each quantised image, we also show an error image  [15] obtained by calculating the difference between the original image and its quantised counterpartFootnote 1. The shown examples further illustrate the excellent colour quantisation results we obtain using our proposed technique and that it yields improved image quality to the other techniques.

Fig. 2.
figure 2

Quantisation results for Sailboat image.

Fig. 3.
figure 3

Quantisation results for Pool image.

Fig. 4.
figure 4

Quantisation results for Airplane image.

5 Conclusions

In this paper, we have proposed a novel quantisation algorithm based on human mental search (HMS), a population-based metaheuristic that mimics exploration strategies in the bid space of online auctions to solve optimisation problems. In our approach, HMS is employed to create a colour palette with the aim of obtaining the highest image quality for the colour quantisation problem. Experimental results on commonly employed test images verify the effectiveness of the proposed algorithm and show our approach to outperform both conventional and soft computing-based colour quantisation algorithms. In future work, we plan to integrate the proposed algorithm with k-means for further improvement, while we also investigate its use in video analysis tasks  [6].