You are on page 1of 10

Modified Firefly Algorithm (MFA) Based

Vector Quantization for Image


Compression

Karri Chiranjeevi, Uma Ranjan Jena, B. Murali Krishna


and Jeevan Kumar

Abstract Firefly algorithm optimization is based on the attractiveness/brightness


of the firefly. In firefly algorithm, a lighter (lesser fitness function) firefly move
towards the brighter firefly (higher fitness function) with amplitude proportional to
Euclidean distance between the lighter and brighter firefly. If no such brighter firefly
is found then it moves randomly is search space. This random move causes chance
of decrement in brightness of the brighter firefly depending on the direction in
which it is move. We proposed a modified firefly algorithm in which movement of
brighter fireflies is towards the direction of brightness instead of random move. If
this direction of brightness is not in the process then firefly is in same position. We
call this novel algorithm as MFA-LBG. Experimental results shows that modified
firefly algorithm reconstructed image quality and fitness function value is better
than the standard firefly algorithm (FA-LBG) and LBG algorithms. It is observed
that that modified firefly algorithm convergence time is less than the standard firefly
algorithm.

Keywords Vector quantization LBG  


Firefly algorithm  Modified firefly
 
algorithm Attractiveness Fitness function

K. Chiranjeevi  U.R. Jena (&)


Department of Electronics and Tele-Communication Engineering,
Veer Surendra Sai University of Technology (VSSUT), Burla 768018
Odisha, India
e-mail: urjena@rediffmail.com
K. Chiranjeevi
e-mail: chiru404@gmail.com
B. Murali Krishna  J. Kumar
Department of Electronics and Communication Engineering,
Sri Sivani Institute of Technology, Srikakulam, Andhra Pradesh, India
e-mail: muralikrishna.bonthu@gmail.com
J. Kumar
e-mail: Jeevan.vajja@gmail.com

© Springer India 2016 373


H.S. Behera and D.P. Mohapatra (eds.), Computational Intelligence
in Data Mining—Volume 2, Advances in Intelligent Systems
and Computing 411, DOI 10.1007/978-81-322-2731-1_35
374 K. Chiranjeevi et al.

1 Introduction

Image compression plays a major role in our day by day life. Coding of image to be
compressed with less number of bits is called image compression. In literature there
are number of image compression methods such as transform method (Discrete
Cosine Transform, Discrete Wavelet Transform, K-L Transform etc.….), fractal
method and optimization methods. Recently it is observed that vector quantization
(VQ) outperforms the scalar quantization. Linde-Buzo-Gary (LBG) algorithm is the
first VQ technique that guarantees the best codebook for each iteration but it suffer
with local minimum i.e. it could not generate global codebook that minimize the
error between original image and reconstructed image [1]. Menez et al. proposed an
Optimum Quantizer Algorithm for Real-Time Block Quantizing [2]. Ra and Kim
proposed a fast mean-distance-ordered partial codebook search algorithm in 1993
[3] they filter the false codewords for an input vector based on the squared mean
distance (SMD). Principal Component Analysis (PCA) is another method to design
a codebook for vector quantization. PCA is based on correlated variables are
transformed to uncorrelated variable. Huang and Harris proposed a directed search
binary-splitting (DSBS) method in 1993 [4]. In their scheme, PCA is used to select
the initial codebook to reduce the dimension of the training vectors. The most
important thing in Vector Quantization is to design a better codebook that mini-
mizes the distortion between original image and reconstructed image. Last few
years it is observed that with optimization techniques for codebook design present a
better reconstructed image quality. Franti et al. proposed [5] a Genetic Algorithm
(GA) based vector quantization for codebook design by considering the codebook
as chromosome. Genetic Algorithm designs an efficient codebook by the process of
crossover and mutation operation. Patane and Russo proposed enhanced LBG
(ELBG) (in 2001) [6] based on the utility of codebook so algorithm overcomes the
problem of local minimum. Utility of jth codebook is defined as the ratio of total
distortion of jth cluster to mean value of the cluster. Rajpoot et al. have designed a
codebook by using ant colony system (ACS) algorithm [7]. Chun-Wei Tsai et al.
proposed a fast ant colony optimization for codebook generation [8] by observing
the redundant operations performed during convergence of ant colony optimization
algorithm. In addition, Practical swarm optimization (PSO) vector quantization [9]
outperforms LBG algorithm which is based on updating the global best (gbest) and
local best (lbest) solution. The Hsuan-Ming Feng, Ching-Yi Chen and Fun Ye
showed that Evolutionary fuzzy particle swarm optimization algorithm gives better
codebook than LBG [10]. Quantum particle swarm algorithm (QPSO) was
Modified Firefly Algorithm (MFA) Based Vector Quantization … 375

proposed by Wang (2007) to solve the 0–1 knapsack problem [11]. Ming-Huwi
Horng proposed a firefly algorithm for vector quantization in 2012 [12].
In Modified firefly algorithm for vector quantization we assumed the current
iteration best solution as a brightest firefly among all. The major problem in normal
firefly algorithm is that these fireflies are moving randomly so there is chance of
decrement in the brightness of fireflies. This kind of move results decrement in
fitness function and also effects on performance of the algorithm. So to overcome
this problem we are moving this type of fireflies towards the direction where chance
of increment in brightness of fireflies is there. So that this movement will not
decrease the fitness function hence generate a global codebook for efficient vector
quantization leading to improved image compression.

2 Vector Quantization Methods

2.1 LBG Vector Quantization

The most commonly used method in VQ is the Generalized Lloyd Algorithm


(GLA) which is also called Linde-Buzo-Gary (LBG) algorithm. The algorithm is as
follows:
Step 1: Begin with initial codebook C1 of size N. Let the iteration counter be
m = 1 and the initial distortion D1 = ∞
Step 2: Using codebook Cm = {Yi}, partition the training set into cluster sets Ri
using the nearest neighbor condition
Step 3: Once the mapping of all the input vectors to the initial code vectors is
made, compute the centroids of the partition region found in step 2. This
gives an improved codebook Cm + 1
Step 4: Calculate the average distortion Dm + 1. If Dm − Dm + 1 < T then stop,
otherwise m = m + 1 and repeat step 2–4

The distortion becomes smaller after recursively executing the LBG algorithm.
Actually, the LBG algorithm can guarantee that the distortion will not increase from
iteration to the next iteration. However, it cannot guarantee the resulting codebook
will become the optimum one and the initial condition will significantly influence
the results. Therefore, in the LBG algorithm we should pay more attention to the
choice of the initial codebook.
376 K. Chiranjeevi et al.

2.2 Firefly Algorithm Vector Quantization

Firefly algorithm works with two assumptions: (1) Irrespective of sex of fireflies all
the fireflies are attracted towards the other fireflies (2) second assumption is that
lighter fireflies are always attracted by the brighter fireflies so lighter one always
moves towards the brighter. If no brighter in the search space then brightest one
moves randomly in search space.
Here our assumption is fitness function is equal to brightness of the fireflies i.e.
lower fitness value fireflies move towards the higher fitness value. According to
theory of physic the brightness/fitness function is monotonically decreasing func-
tion. Suppose a distance ri,j = d(Xj, Xi) is the Euclidean distance between the chosen
jth firefly to ith firefly which is given by Eq. (1).
vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
u Nc L
uX X
Euclidean distance rij ¼ kXI  XJ k ¼ t ðXi;kh  X h Þ2
j;k ð1Þ
k¼1 h¼1

b ¼ b0 ecri;j ð2Þ

where β0 is the brightness at ri,j = 0 and β is the light absorption coefficient at the
source. With this β and Euclidean distance, the lighter firefly i move towards the
brighter firefly j as per the following Eq. (3)

Xi;k ¼ ð1  bÞXi;k þ bXj;k þ ui;k ð3Þ

1
ui;k ¼ aðrand 1  Þ ð4Þ
2

where α is a random number.


If no brighter firefly in the search space than firefly Xi then it moves randomly
with Eq. (5)

Ximax ;k ¼ Xiþ
max ;k uimax ;k ð5Þ

where rand1 value is lies between 0 to 1. The objective function in firefly algorithm
is equal to the brightness of the firefly.
Modified Firefly Algorithm (MFA) Based Vector Quantization … 377

The details of FF-LBG algorithm is as follows:


Step 1: Run the LBG algorithm once and assign it as brighter codebook
Step 2: Initialize α, β and γ parameters, Initialize rest codebooks with random
numbers
Step 3: Find out fitness values by Eq. (6) of each codebook

1 Nb
FitnessðCÞ ¼ ¼ N N ð6Þ
DðCÞ P c Pb  2
uij  Xi  Cj 
j¼1 i¼1

Step 4: randomly select a codebook and record its fitness value. If there is a
codebook with higher fitness value, then it moves towards the brighter
codebook (highest fitness value) based on the Eqs. (7)–(9).
vffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
u Nc L
uX X
Euclidean distance rij ¼ kXI  XJ k ¼ t ðXi;kh  X h Þ2
j;k ð7Þ
k¼1 h¼1

Xi is randomly selected firefly, Xj is brighter firefly

b ¼ b0 eci;j ð8Þ
h h h
Xj;k ¼ ð1  bÞXi;k þ bXj;k þ uhj;k ð9Þ

where u is random number between 0 and 1, k = 1, 2,…,Nc, h = 1, 2,….L.


Step 5: if no firefly fitness value is better than the selected firefly then it moves
randomly is search space with following equation
h h
Xi;k ¼ Xi;k þ uhj;k k ¼ 1; 2. . .Nc ; h ¼ 1; 2; . . .:L ð10Þ

3 Modified Firefly Algorithm

Surafel et al. [13] proposed a modified firefly algorithm in the year 2012 [13]. In
ordinary firefly algorithm, if no brighter firefly in the search space then the firefly
under consideration moves randomly where as in modified firefly algorithm the
random movement is towards the firefly whose brightness is going to be increased
[14]. To know the brightness directions generate randomly Y unit vectors i.e. Y1,
Y2, Y3…. Ym and then choose a firefly randomly whose brightness is increased in
next iteration. The movement of the brightest firefly follows the following Eq. (11)
378 K. Chiranjeevi et al.

Y ¼ Y þ aR ð11Þ

where α is a random step length. If firefly does not find such kind of firefly then it
stays in the current position.
The detailed algorithm is as follows:
Step 1: Run the LBG algorithm once and assign it as brighter codebook
Step 2: Initialize α, β and γ parameters, Initialize rest codebooks with random
numbers
Step 3: Find out fitness values by Eq. (6) of each codebook
Step 4: randomly select a codebook and record its fitness value. If there is a
codebook with higher fitness value, then it moves towards the brighter
codebook (highest fitness value) based on the Eqs. (7)–(9)
Step 5: if no firefly fitness value is better than the selected firefly then it moves
with Eq. (11) else it stays in the same position

4 Results and Discussions

The modified firefly algorithm, current firefly algorithm and LBG have been
implemented using Matlab 7.9.0 (R2009b), and then these three algorithms are
tested and compared with each other using the two selected images. Images were
used for comparison are peppers (.png format) and baboon (.jpg format). Figure 1
shows the images used for comparison of three methods. The image statistics
namely, fitness function and PSNR (Peak Signal to Noise Ratio) afford the per-
formance measure of an image compression technique. Figure 2a–c shows the
reconstructed baboon image or decompressed baboon images of three algorithms
and it is observed that reconstructed image quality of modified firefly algorithm is

Fig. 1 Standard image used for comparison for three methods. a Baboon. b Peppers
Modified Firefly Algorithm (MFA) Based Vector Quantization … 379

Fig. 2 Decompressed baboon images of three methods. a LBG. b FA–LBG. c MFA–LBG

Fig. 3 Decompressed pepper images of three methods. a LBG. b FA–LBG. c MFA–LBG

better than firefly algorithm and LBG algorithms. Figure 3a–c shows the recon-
structed peppers image or decompressed peppers image of three algorithms. The
indicated yellow and red marks on peppers image shows that reconstructed image
quality of modified firefly algorithm is better than firefly algorithm and LBG
algorithms.
Figure 4a, b shows the peak signal to noise ratio verses bit rate for three
methods. From the figures it is observed that peak signal to noise ratio of modified
firefly algorithm is better than firefly algorithm and LBG algorithms. From practical
observation the modified firefly algorithm convergence speed is better than ordinary
firefly algorithm. From Fig. 5 represents the Cost of fitness function. From Figures
fitness function of modified firefly algorithm is better than firefly algorithm and
LBG algorithms. Figure 5a, b shows the reconstructed image or decompressed
images of three algorithms and it is observed that reconstructed image quality of
modified firefly algorithm is better than firefly algorithm and LBG algorithms.
380 K. Chiranjeevi et al.

Fig. 4 Average peak signal to noise ratio of three methods. a Baboon image. b Peppers image
Modified Firefly Algorithm (MFA) Based Vector Quantization … 381

Fig. 5 Average fitness function value of three methods. a Baboon image. b Peppers image

5 Conclusions

In this paper, a Modified Firefly algorithm (MFA) optimized vector quantization for
image compression is proposed. From the simulation results it is observed that
modified firefly algorithm peak signal to noise ratio and fitness function value is
better than the firefly algorithm (FA-LBG) and LBG algorithms. From the simu-
lation results it is observed that that modified firefly algorithm convergence time is
less than the standard firefly algorithm.
382 K. Chiranjeevi et al.

References

1. Lloyd, S.P.: Least squares quantization in PCM’s. In: Bell Telephone Laboratories Paper,
Murray Hill, NJ (1957)
2. Menez, J., Bceri, F., Esteban, D.J.: Optimum quantizer algorithm for real-time block
quantizing. In: Proceedings of the I979 IEEE Internal Conference on Acoustics, Speech, &
Signal Processing, pp. 980–984. (1979)
3. Ra, S.W., Kim, J.K.: A fast mean-distance-ordered partial codebook search algorithm for
image vector quantization. IEEE Trans. Circuits Syst. II: Analog Digital Signal Process. 40(9),
576–579 (1993)
4. Huang, C.M., Harris, R.W.: A comparison of several vector quantization codebook generation
approaches. IEEE Trans. Image Process. 2(1), 108–112 (1993)
5. Franti, P., Kivijarvi, J., Kaukoranta, T., Nevalainen, O., et al.: Genetic algorithms for
codebook generation in vector quantization. In: Proceedings of the 3rd Nordic Workshop on
Genetic Algorithms (3NWGA), Helsinki, Finland, pp. 207–222. (1997)
6. Patane, G., Russo, M.: The enhanced LBG algorithm. Neural Netw. 14, 1219–1237 (2002)
7. Rajpoot, A., Hussain, A., Saleem, K., Qureshi, Q.: A novel image coding algorithm using ant
colony system vector quantization. In: International Workshop on Systems, Signals and Image
Processing, Poznan, Poland
8. Tsaia, C.-W., Tsengb, S.-P., Yangc, C.-S., Chiangb, M.-C.: PREACO: a fast ant colony
optimization for codebook generation. Appl. Soft Comput. 13, 3008–3020 (2013)
9. Chen, Q., Yang, J.G., Gou, J.: Image compression method by using improved PSO vector
quantization. In: First International Conference on Neural Computation (ICNC 2005), Lecture
Notes on Computer Science, vol. 3612, pp. 490–495. (2005)
10. Feng, H.-M., Chen, C.-Y., Ye, F.: Evolutionary fuzzy particle swarm optimization vector
quantization learning scheme in image compression. Expert Syst. Appl. 32, 213–222 (2007)
11. Wang, Y., Feng, X.Y., Huang, Y.X., Pu, D.B., Zhou, W.G., Liang, Y.C.: A novel quantum
swarm evolutionary algorithm and its applications. Neurocomputing 70, 633–640 (2007)
12. Horng, M.-H.: Vector quantization using the firefly algorithm for image compression. Expert
Syst. Appl. 39, 1078–1091 (2012)
13. Tilahun, S.L., Ong, H.C.: Modified firefly algorithm. In: School of Mathematical Sciences,
Universiti Sains Malaysia, 11800 Minden, Penang, Malaysia (2012)
14. Chandra Sekhar, G.T., et al.: Load frequency control of power system under deregulated
environment using optimal firefly algorithm. Int. J. Electr. Power Energy Syst. 74, 195–211
(2016)

You might also like