Keywords

1 Introduction

Image compression [1,2,3] is essential because the education system is using the online platform for teaching, and demand increases for digital notes to be shared with students all over the world. As doctors are doing research on placid trail for patients of COVID-19, the same numerous data storage of patient increases. It improves the transmission speed of information to be transmitted or received in hybrid communication channel and furthermore modern applications [4, 5]. Image compression is classified into a lossy image compression [6] and lossless image compression. These techniques are challenging that to achieve a good compression ratio [7, 8]. Due to small information loss, quality of restoration is poor in lossy method [9, 10]. Lossless image compression technique is having negligible loss [11, 12]. Therefore, the data of the encoder and decoder are closely similar, and the restoration quality is good. Depending on application, researchers can select lossy or lossless image compression [13,14,15].

Research flow is as follows:

  1. 1.

    This research work is based on vector quantization.

  2. 2.

    The input image is divided into 4 by 4 blocks, and that input vectors are represented by 16-bit codeword.

  3. 3.

    Modified GA and PSO are codebook optimization algorithms, and they are used to improve compression ratio.

  4. 4.

    To achieve good compression ratio, error must be minimum.

  5. 5.

    In the end, the analysis of the BPP and CR is compared.

The work is prepared in following sections. Section 2 scrutinizes the literature survey. Section 3 presents vector quantization method, and Sect. 4 exposes modified GA and PSO. Section 5 presents the experiments, and research work is concluded in Sect. 6.

2 Literature Review

2.1 Contribution by Researchers

In 2020, Shakya, Subarna, and Lalitpur, Nepal Pulchowk introduced a novel bi-velocity particle swarm optimization scheme for multicast routing problem. Dhaya R. and R. Kanthavel introduced comprehensively meld code clone identifier for replicated source code identification in diverse web browsers. Daniela Sánchez, Patricia Melin, and Oscar Castillo have investigated the firefly algorithm (FF) [6]. Blinking characteristics of fireflies are used in this model. One important feature is that regardless of their sex, fireflies are attracted to one another. Brighter the control attractiveness, brighter the firefly attracts the less bright firefly, else move by chance. Proficient codebook is designed using firefly algorithm [16]; the challenge is less availability of brighter fireflies in exploring.

In 2019, Panda and Das [17] have introduced a gray wolf optimizer (GWO). The gray wolves have hunting behavior and leadership hierarchy. This algorithm is character-motivated algorithm and used for optimization [18]. Neighboring region is supported for the primary elucidation of every progression to produce the best outcome. If termination criteria are not fulfilled, then step will be continued [19].

In 2018, Cui, Z., Li, F. and Zhang, W. have introduced VQ-based bat algorithm (BA). BA is used for image compression. BA technique improves the result. The codebook is designed efficiently by varying all possible parameters.

In 2016, Mirjalili and Lewis [20] have presented whale optimization algorithm. WOA follows the group performance. This algorithm is encouraged through the bubble-net track approach. This is a popular optimization algorithm when it is evaluated with conventional methods [21]. Hence, all these features are considered in this research work along with the challenges faced by these optimization algorithms. This paper is enlightening the performance of image compression models by GA and PSO algorithms.

2.2 Problem Definition

New era of internet is demanding for compressed image for the same need to design an optimal codebook with better compression rate and minimum error at reconstructing image [1]. Researchers have proposed optimization techniques for codebook generation because the performance of VQ depends on codebook. Image compression model using modified genetic algorithm was presented in [2] that provides minimized error at reconstructing the image. Selection, crossover, and mutation operators are used for codebook design. Outcomes were satisfactory appropriate to its unique chromosome feature use in the codebook design. Limitation of modified GA is that it undergoes more execution time when population size is large. The researcher has proposed another optimization technique called particle swarm optimization (PSO) [3]. It offers a superior efficiency and better compression ratio. It initializes the swarm size and calculates the fitness value. Those who are best fit swarm, that position is updated by replacing previous swarm. The steps are repeated until it fulfills the criteria. If the position of the swarm is not varied or the termination criteria are satisfied, then stop. The best position of the particles is updated. For the maximum particle velocity, instability occurs in the particles. It is necessary for analyzing these optimization models to get better image compression results.

2.3 Motivation

Optimization algorithms, specialization, and problem face for image compression are described in Table 1. At first, the modified genetic algorithm has been implemented [2] which reduces artifact impacts and simplifies the design of the codebook. Modified GA is based on natural characteristics, so there would be no chances of duplications and gives better results. Modified GA has challenge to produce optimal outcomes. Likewise, second algorithm has explored a novel approach by vector quantization for image compression using particle swarm optimization (PSO) algorithm, which is a superior model. PSO is high quality and better than other optimization model. Therefore PSO model could outperform the other image compression standards. Analysis of these optimization models is to be presented in this paper.

Table 1 Characteristics and problems face in various image compression models

3 Novel Idea of the Proposed Technique Andmodels

3.1 A. Vector Quantization and Codebook Optimization Method

VQ process is superior to scalar quantization techniques. VQ can reduce the distortion with the number of reconstruction levels in keeping constant. Scalar quantization quantizes every value individually.

Figure 1 shows scalar quantization. Vector quantization is complex method and quantizes several values jointly. VQ is usual a lossy image compression technique and presents good compression ratio as shown in Fig. 2.

Fig. 1
A diagram depicts scalar quantization, which has 3 vertical and horizontal lines with points. The range of both Y-axis and X-axis is 255.

Scalar quantization

Fig. 2
A diagram depicts vector quantization, and has 2 diagonal lines with 3 points in a 255 by 255 square.

Vector quantization

Vector quantization is a conventional methodology for image compression. As a main contribution, codebook is optimized in such a way that it minimizes error in the reconstructed image. A few images from the database are used for the codebook generation. Set of blocks is presented as vectors. The encoder sends their indices to achieve a compression through a channel. Output file reconstructs the image by placing correct vectors on the image with the help of decoder. The codebook is optimized using optimization algorithms, i.e., GA and PSO, and we could get better results. In this paper, we are presenting the analysis using these optimization algorithms. The architecture of the vector quantization is demonstrated in Fig. 3.

Fig. 3
An illustration depicts how the original image is encoded with codeword and index and obtained the reconstructed image by the decoder with codeword and index.

Architecture of the vector quantization

3.2 Codebook Structure and Fitness Function

The codewords cd1 are stored in the codebook cb1. The size of the codebook can be changed depending upon the size of the input image. Codebook cb1 consists of 256 codewords, i.e., cd1 (1, 1), cd1 (1, 2) … cd1 (1, 256). These codewords are divided further in three parts, viz. the code of codebook (cbook1), indices/positions of codebook (imgind1), and their corresponding image value/pixel (imgcd1). Figure 4 shows the structure of the codebook. A set of chromosomes is stored in cbook1 of cd1 (1, 1) by the process of chromosome selection, and then crossover and mutation are performed on these stored chromosomes. The selection of chromosome, crossover, and mutation take place on a random basis. Then again a new set of chromosomes is selected for cd1 (1, 2), and the entire process is repeated again up to cd1 (1, 256). 0–255 blocks can be designed in the codebook, and up to 256 codewords are presented for distribution [1]. To design the codebook in such a way that it minimizes the image compression effect.

Fig. 4
A structure depicts a 256-size codebook with the 16-bit codebook code followed by the index and its corresponding pixel or image values.

Structure of codebook

The tradeoff between the number of codeword selected and the extent to which distortion in the image is bearable must be decided [11]. The traditional vector quantization techniques failed to cope up with this requirement to some extent. Thus, for designing an optimal codebook design, the principles of clustering are applied to the traditional vector quantization algorithm. Image is initially divided into n × n non-overlapping subdivisions. The similar data vectors are then identified from these subdivisions (blocks) and placed into similar groups. Codebook is generated with the reference input vectors, and then we apply a quantization process. Now, instead of selecting a separate codeword for each of the vectors, the same codeword is selected for all the vectors that are placed in the same group and the process of vector quantization is carried out for generation of an optimal codebook. Thus, clustering reduces the number of codewords to be used in the codebook design [3]. The lesser the number of codewords used the higher is the compression ratio achieved and lesser is the image distortion. The identical index of this codeword is transmitted at output file. Figure 5 shows the image division into 4 × 4 non-overlapping blocks and the initial codebook generated using vector quantization.

Fig. 5
A screenshot depicts how an input image of a woman is compressed, along with the parameters of codebook size, iteration, and block size.

Image division into 4 × 4 non-overlapping block and codebook generated using vector quantization

Efficiency of genetic algorithm depends on fitness, and it is used for the selection of chromosomes. Fitness is calculated with the help of MSE.

3.3 Algorithm for Initial Codebook Generation is Given as Follows

Algorithm for initial codebook generation

Step 1: Input image as training set

Step 2: The input image is converted into appropriate structure by dividing it into non-overlapping blocks

Step 3: The blocks of image to be selected for a codeword are picked up on the basis of the code in MATLAB

Step 4: Calculate fitness of all solutions

Step 5: Evaluate the best fitness function

for I = 1: n hpsnr = 0

for j = 1: q level if tpsnr > hpsnr

hpsnr = tpsnr;

best_unit = j;

end

next j

next i

end

Number of blocks that belong to the codebook (best-unit) + 1; allocate the block position to the blocks that belong to the best unit in the array of codebook; here, n is the number of blocks in the input image, and q level corresponds to the quantization level used.

3.4 Quality Measures Are as Follows

3.4.1 Peak Signal-to-Noise Ratios (PSNR)

In image compression, PSNR measures appearance the quality of the image to a detrimental level. PSNR equation is as follows (1),

$$ {\text{PSNR}} = 10\log10\left( {255 \times \frac{255}{{{\text{MSE}}}}} \right) $$
(1)
$$ \begin{aligned} {\text{PSNR}} & = 10\cdot \log_{10} \left( {\frac{{{\text{MAX}}_{I}^{2} }}{{{\text{MSE}}}}} \right) \\ & = 20\cdot\log_{10} \left( {\frac{{{\text{MAX}}_{I} }}{{\sqrt {{\text{MSE}}} }}} \right) \\ & = 20\cdot\log_{10} \left( {{\text{MAX}}_{I} } \right) - 10\cdot\log_{10} \left( {{\text{MSE}}} \right) \\ \end{aligned} $$

Here, MAXI is the maximum possible pixel value of the image. Let us consider pixels are 8 bits per sample, then it is 255. In the absence of noise, images I and K are same and thus the MSE is zero. Practically, PSNR is around 30 dB.

3.4.2 Mean Square Error (MSE)

Calculate variations among the actual and reference pixel, and its average is represented by mean squared error. MSE is measured as (2).

$$ {\text{MSE}} = \frac{1}{mn}\mathop \sum \limits_{i = 0}^{m - 1} \mathop \sum \limits_{j = 0}^{n - 1} \left[ {I\left( {i,j} \right) - K\left( {i,j} \right)} \right]^{2} $$
(2)

3.4.3 Structural Similarity (SSIM) Index

It is a quality measure, and its score is represented by an Eq. (3)

$$ {\text{SSIM}} \left( {x,y} \right) = \left[ {l\left( {x,y} \right)} \right]^{\alpha } \cdot \left[ {c\left( {x,y} \right)} \right]^{\beta } \cdot\left[ {s\left( {x,y} \right)} \right]^{\gamma } $$
(3)

SSIM is concerned with quality measurement method to local region using a sliding window approach. Size of B × B moves horizontally and vertically from top-left corner to bottom-right corner, all over the image. Accuracy of SSIM is great but acquires more computational cost.

3.4.4 Average Difference (AD)

The difference between the input image and output image in image compression is represented as (4)

$$ {\text{AD}} = \frac{1}{{{\text{MN}}}}\mathop \sum \limits_{i = 1}^{M} \mathop \sum \limits_{j = 1}^{N} \left( {x\left( {i,j} \right) - y\left( {i,j} \right)} \right) $$
(4)

where x(i, j) represents the input (reference) image and y (I, j) represents output image.

4 Codebook Optimization Models

4.1 Modified Genetic Algorithm

Modified genetic algorithm is used as a natural characteristic for optimization of codebook design in vector quantization for image compression.

Modified GA steps are as follows:

Procedure: Modified Genetic Algorithm

Generation of initial chromosomes

While, iterations τ< τoff

for τ = 1 to100

Step 3: Calculate the fitness of all solutions

Step 4: Evaluate the best fitness function

Step 5: Selection operator: Select the best fit parent chromosome

Step 6: Crossover operator: Select the best fit children chromosomes

Step 7: Mutation operator: Mutate other children chromosome than the best fitting one

Step 8: Find best fitness solutions

Step 9: Update the best fitness chromosome

Step 10: Termination: if the criterions are satisfied

Step 11: If not then Return step 2

Step 12: τ= τ + 1

 end for end while

End

Quality of codebook depends on fitness, and fitness is better for minimum error in reconstructed image. Clustering is used to cluster similar data into same block. Genetic operators are selection, crossover, and mutation.

Selection of the best fit children chromosome:

  1. (1)

    Generate random population of n chromosomes.

  2. (2)

    Calculate the fitness of each chromosome in the population.

  3. (3)

    Select two parent chromosomes those who are best fit.

  4. (4)

    Crossover the parents to generate a children.

  5. (5)

    Apply mutation probability.

  6. (6)

    Place best fit children in a new population.

4.2 Particle Swarm Optimization Algorithm

This method is for optimizing the codebook through the significance of each particle and exploit pbest and best to focus the automatic clustering. Clustering reduces the computational complexity, while the stochastic search method of PSO algorithm helps in obtaining an optimal solution [3, 6]. PSO is a multi-agent approach based on the bird flocking and used for optimization. It is starting with a random particle solution. They move to search for optima by renewing iterations and each particle by two “best” values. The best solution (fitness) it has reached and referred as pbest. Another “best” value in the population is a global best and referred as gbest. In this model, xi is particle position and vi is velocity. The best position in the vector is pbest. Updated velocity is found with the help of Eqs. (5) and (6).

$$ Vid^{\prime} = w*vid + c1*r1*\left( {p{\text{best}} - xid} \right) + c2 * r2 * \left( {g{\text{best}} - xid} \right) $$
(5)
$$ Xid^{\prime} = xid + Vid^{\prime} $$
(6)

Inertia weight is represented by w, random numbers are r1 and r2, coefficient of the self-recognition component is c1, social component is c2, and both are positive constant. Based on the best position, particle leads effectively in the search space. The development of PSO [3] is based on a particle's position toward a target location.

Steps of PSO:

Procedure: Particle swarm optimization

Step 1: Selection of particle

Step 2: Calculate fitness

Step 3: Update pbest

Step 4: Select gbest

Step 5: Particle velocity calculation

Step 6: Renew position of the particle

Step 7: Steps are repeated till termination criteria are achieved

Velocity and position of each particle are randomly initialized. Particle maintains its pbest (local best position) and gbest (global best position). To renew the position of given particle, current position of these particles should be better than the previous one.

5 Experimental Results

The PSO and GA were tested in MATLAB. In this database included category 1, 2, 3, and 5 images were downloaded from standard database and for category 4 were manually collected.

The analysis of the compression ratio and BPP is demonstrated in Table 2. Results are compared with other algorithms [17,18,19,20,21]. The original image is shown in following Fig. 6, and decompressed by modifying GA is shown in Fig. 7, and Fig. 8 shows decompressed by PSO. CR analysis of optimization algorithms is shown Fig. 9.

Table 2 Types of images and sets
Fig. 6
5 greyscale photographs of a brick wall, a butterfly in a leaf, a tissue with nerves, a satellite map, and a car on a road.

Original image: a texture image, b nature image, c medical image, d satellite image, and e miscellaneous image

Fig. 7
An illustration depicts a decompressed image of a brick wall, a butterfly in a leaf, a tissue with nerves, a satellite map, and a car on a road, where features are extracted.

Decompressed image by modifying GA: a texture image, b nature image, c medical image, d satellite image, and e miscellaneous image

Fig. 8
An illustration depicts a decompressed image of a brick wall, a butterfly in a leaf, a tissue with nerves, a satellite map, and a car on a road, with clear textures.

Decompressed image by PSO: a texture image, b nature image, c medical image, d satellite image, and e miscellaneous image

Fig. 9
A bar graph compares the compression ratios of different algorithms. P S O and F F have a high and low compression ratio of approximately 98 and 54, respectively.

CR analysis of optimization algorithms

We are also demonstrating results on gray-level image. The parameter used in the experimentation is population size: 50 and 100. We continue this uniformity testing. We have set different iterations: 10 and 50. In the experimentation, we divide the image into 4 × 4 and 8 × 8 blocks to encode. We have designed a codebooks using optimization algorithms. In the output file, send indexes to represent every codeword. Initial population is selected with best fitness chromosomes. It has been observed [1, 2] that if the initial chromosomes are fit, then the solution of clustering would be best as it has much depends on them. The result shows that quality measure parameters are achieved by PSO which is greater than the modified genetic algorithm. Training sets (Fig. 10) are taken with size 512X512, and reconstructed image is shown in Fig. 11. Performance analysis of optimization algorithms are shown in Figs. 12, 13, 14, 15, 16, 17, 18 and 19. Comparison of quality measures is shown in Tables 3 and 4.

Fig. 10
A screenshot depicts how a compressed image is transferred into a reconstructed image of a woman, along with the parameters of iteration, block size, and population.

Training image of Leena (512 × 512)

Fig. 11
A greyscale photograph of Leena.

Reconstructed image of Leena

Fig. 12
A bar graph compares the P S N R of different algorithms. P, I, B of 100, 50, 4, and P, I, B of 50, 50, 8 have a high and low P S N R of approximately 36 and 31.8, respectively.

PSNR analysis of optimization algorithms

Fig. 13
A bar graph compares the M S E of different algorithms. P, I, B of 50, 10, 8, and P, I, B of 100, 10, 8 have a high M S E of approximately 850.

MSE analysis of optimization algorithms

Fig. 14
A bar graph compares the S S I M of different algorithms. P, I, B of 50, 10, 8, and P, I, B of 100, 50, 4 have a high and low S S I M of approximately 0.79 and 0.6, respectively.

SSIM analysis of optimization algorithms

Fig. 15
A bar graph compares the A D of different algorithms. P, I, B of 50, 10, 8, and P, I, B of 100, 50, 4 have a high and low A D of approximately 10 and 4, respectively.

AD analysis of optimization algorithms

Fig. 16
A bar graph compares the P S N R of different algorithms. P, I, B of 100, 50, 4, and P, I, B of 100, 10, 8 have a high and low P S N R of approximately 34 and 25, respectively.

PSNR analysis of optimization algorithms

Fig. 17
A bar graph compares the M S E of different algorithms. P, I, B of 100, 10, 8, and P, I, B of 100, 50, 4, have a high and low M S E of approximately 900 and 300, respectively.

MSE analysis of optimization algorithms

Fig. 18
A bar graph compares the S S I M of different algorithms. P, I, B of 50, 10, 4, and P, I, B of 100, 50, 4, have a high and low S S I M of approximately 0.7 and 0.5, respectively.

SSIM analysis of optimization algorithms

Fig. 19
A bar graph compares the A D of different algorithms. P, I, B of 50, 10, 8, and P, I, B of 100, 10, 8, have a high A D of approximately 10.

AD analysis of optimization algorithms

Table 3 Comparison of quality measures block size of 4 × 4 and 8 × 8, iteration 10 and 50, population size 50 and 100 using the PSO algorithm on grayscale image 512 × 512 and codebook size = 256
Table 4 Comparison of quality measures with block size of 4 × 4 and 8 × 8, Iteration 10 and 50, Population size 50 and 100 using modified GA algorithm on grayscale image 512 × 512 and codebook size = 256

6 Conclusion

Analysis of image compression has been simulated in MATLAB, and the experimentations have been carried out. The performance of the PSO algorithm is to be compared with a modified GA algorithm in terms of analysis on error measures like PSNR, MSE, SSIM, and AD. Experimental results show that the PSO is better than the modified genetic algorithm. We have shown that PSO outperforms the image compression standard. A bitrate, BPP, is 8. The compression ratio for PSO is 90.90%, for FF it is 75%, GWO it is 83.33%, and 80% of modified GA. The experimental results indicate clear superiority of PSO over the existing techniques. From result, we have proved that the % of the CR of PSO model is best among other models.