=Paper=
{{Paper
|id=Vol-1730/p02
|storemode=property
|title=First Attempt of Rapid Compression of 2D Images Based on Histograms Analysis
|pdfUrl=https://ceur-ws.org/Vol-1730/p02.pdf
|volume=Vol-1730
|authors=Danuta Jama
|dblpUrl=https://dblp.org/rec/conf/system/Jama16
}}
==First Attempt of Rapid Compression of 2D Images Based on Histograms Analysis==
First Attempt of Rapid Compression of 2D Images Based on Histograms Analysis Danuta Jama Institute of Mathematics Silesian University of Technology Kaszubska 23, 44-100 Gliwice, Poland Email: Danuta.Jama@polsl.pl Abstract—Expanding technological advances and digitization size of digital data is just one of the reasons for developing this generate more and more data, so the amount of space to subject. The second reason is the considerable development store them is greater. To minimize the amount of stored data, of related branches of computer science such as artificial efficient compression algorithms are needed. In this paper, the idea of the use of histograms for analysis of 2D images for intelligence methods that expand the possibilities of action of the purpose of compression is shown. Performance tests were compression algorithms. carried out, presented and discussed in terms of advantages and In 2012, Vikas Goyal [1] introduced the use of wavelet disadvantages. coding for the purpose of minimizing the size of image files. In addition, analysis of the use of different wavelets (including I. I NTRODUCTION Haar or Dauchechies) EZW algorithm has been presented. Digital imagery has a huge impact on our lives. In every Similarly, the authors of [2] presented an algorithm based on place on earth, at any time, a person has access to their data the combination of wavelet theory and chaos theory (fractals). using a laptop or a cell phone connected to the Internet. And For comparison, Cenugopal et al. [3] proposed the use of thus, the exchange of data between two points on the globe is Arnold transform with chaos encoding technique showing the no longer a problem. On the other hand, Internet has caused effectiveness of the creation of hybrid algorithms. In a similar a wave of popularity of various social networking sites where time, Zhou et al. [4] presented the idea of encryption hybrid people publish various photos of their life. This is just one algorithm based on key-controlled measurement matrix. of the phenomena of the last years, which intensified the The rapid development of artificial intelligence methods amount of data and exchange information in the network at allowed to take a more random direction of compression, least several times. which can be seen on the example of the use of heuristic These issues have caused several problems. First, the data algorithms [5]–[7], or fuzzy logic [8], [9], what helped gain a traffic burden the entire network, so the upload speed or significant advantage over other existing algorithms in terms of download can be reduced at the time. Secondly, the amount weight input files. And in [10], the authors introduced a novel of data grows every day - files must be stored somewhere, so predictor using causal block matching and 3D collaborative the number of servers will also increase. These are problems filtering. that can not be solved, but we can minimize them. Increasingly, modern computer science uses the latest Data compression algorithms rely on conversion method of achievements, but that does not mean that the older mathe- writing data in such a way that the weight of the data was matical theories such as Fourier transforms are no longer used smaller. In other words, the input file should be processed in – in [11]–[14], a new approach to the use of either transform order to save the file to a smaller number of bits. is described. Again in [15], Fracastoro et al. pointed to the use Compression algorithms can be divided into two types - of transformation based on graphs. lossless and lossy. Lossless methods do not change the con- In this paper, lossy compression algorithm for 2D images tents of the file, so the only form of writing a file is changed. based on the analysis of the histogram is presented. The best-known algorithms is Huffman and Shannon-Fano coding, LZW or PNG. On the other hand, lossy algorithms III. C OMPRESSION A LGORITHM operate by manipulating not only a record but also the quality To optimize the amount of compressed material from two- of the file, eg .: DPCM or JPEG. dimensional images, specific areas will be analyzed using the mechanism of the grid. The grid of size n pixels gets the area II. R ELATED W ORK of the image and processes it. Then, the grid is shifted by n In recent years, data compression algorithms are experienc- pixels and the operation is repeated until the entire image will ing a renaissance. The demand for methods of reducing the not be covered with the grid. The processing of the the grid is to calculate the histogram Copyright c 2016 held by the author. and check whether the histogram exceeds the threshold value γ (see Fig. 2, where a sample histogram is cut by the threshold 9 value). In the case where histogram of the area covered by a grid exceeds the threshold value, all the colors of pixels are scaled using the following formula ( αK if αK < 256 CK = , (1) 255 if αK > 255 where K means a specific color component from the RGB model (R, G or B) and α is a given parameter in the range of h0, 2i. The parameter α manipulates the brightness of the image what can be represented as h0, 1) dim image α= 1 normal image . (2) (1, 2i brighter image The implementation of the described technique is presented in Algorithm 1. Algorithm 1 The algorithm color change based on a histogram 1: Start 2: Load the image 3: Define the grid sizen and a threshold value γ 4: Define an array representing the values of the histogram 5: max := 0 6: while grids does not cover the entire image do 7: Load the grid on the current position 8: for each pixel in the grid do 9: Get the red value of a pixel to actualV alue 10: Increase the value of 1 in the array histogram at the position actualV alue 11: if max < actualV alue then 12: max = actualV alue 13: end if 14: end for 15: θ := f alse 16: for each value ω in the histogram array do 17: if ω ≥ γ then 18: θ = true 19: end if 20: end for 21: if θ == true then 22: for each pixel in the grid do 23: Recalculate color value using (1) 24: end for 25: end if 26: Move the position of the value of n 27: end while 28: Stop IV. E XPERIMENTS The algorithm has been tested for different sized images from the database Earth Science World Image Bank (available Fig. 1: A simplified model of the algorithm. here – www.earthscienceworld.org). During the tests, the grid The images were used only for research purposes and the author does not derive any financial benefit. 10 Fig. 2: The histogram with selected threshold value (red line). size was set to 81 pixels, and thus 9 × 9 and a threshold value Fig. 4: The dependence of the average time from the size of was set as 0.4. the image. Performed tests showed that for the small parameters α and γ, the image is darker but with a smaller size. The measurement results can be seen in Figures 5, 6 and 7. The In future work, the design of the algorithm reverse is weight of each file was measured before and after compres- planned. This method, lossy compression of the file and the sion. Graphical comparison of the size is shown in Figure 3. ability to recover lost data would enable a much better flow The effectiveness of the proposed method was measured using of data on the Internet, because the two sides could have the the arithmetic mean. For some parameters, the compressed original file, where the transferred file would be not only lower image has average 3.1 times lower weight. The dependence quality, but much smaller size. of the average running time of the algorithm from the size R EFERENCES of the image is presented in Fig. 4. The image file is larger, the more time is needed to perform all operations. The time [1] V. Goyal, “A performance and analysis of ezw encoder for image compression,” GESJ: Computer Science and Telecommunications, no. 2, required for compression increases linearly for files composed p. 34, 2012. of a maximum of 150 000 pixels. For larger files, the time [2] A. Al-Fahoum and B. Harb, “A combined fractal and wavelet angiogra- increases fourfold. phy image compression approach,” The Open Medical Imaging Journal, vol. 7, pp. 9–18, 2013. [3] D. Venugopal, M. Gunasekaran, and A. Sivanatharaja, “Secured color image compression and efficient reconstruction using arnold transform with chaos encoding technique,” signal, vol. 4, no. 5, 2015. [4] N. Zhou, A. Zhang, F. Zheng, and L. Gong, “Novel image compression– encryption hybrid algorithm based on key-controlled measurement ma- trix in compressive sensing,” Optics & Laser Technology, vol. 62, pp. 152–160, 2014. [5] M.-H. Horng, “Vector quantization using the firefly algorithm for image compression,” Expert Systems with Applications, vol. 39, no. 1, pp. 1078–1091, 2012. [6] R. Ramanathan, K. Kalaiarasi, and D. Prabha, “Improved wavelet based compression with adaptive lifting scheme using artificial bee colony algorithm,” International Journal of Advanced Research in Computer Engineering & Technology (IJARCET), vol. 2, no. 4, pp. pp–1549, 2013. [7] S. Yang, S. Wang, Z. Liu, M. Wang, and L. Jiao, “Improved bandelet with heuristic evolutionary optimization for image compression,” Engi- neering Applications of Artificial Intelligence, vol. 31, pp. 27–34, 2014. [8] V. S. Thakur and K. Thakur, “Design and implementation of a highly Fig. 3: Comparison of the size of files before and after efficient gray image compression codec using fuzzy based soft hybrid compression. jpeg standard,” in Electronic Systems, Signal Processing and Computing Technologies (ICESC), 2014 International Conference on. IEEE, 2014, pp. 484–489. [9] D. M. Tsolakis and G. E. Tsekouras, “A fuzzy-soft competitive learning approach for grayscale image compression,” in Unsupervised Learning V. C ONCLUSION Algorithms. Springer, 2016, pp. 385–404. [10] R. Crandall and A. Bilgin, “Lossless image compression using causal The proposed method of compression of graphic images is block matching and 3d collaborative filtering,” in Image Processing able to reduce the image size by more than 50% with a good (ICIP), 2014 IEEE International Conference on. IEEE, 2014, pp. 5636– 5640. selection of threshold values. The biggest drawback of the [11] M. Gupta and A. K. Garg, “Analysis of image compression algorithm algorithm is the large decrease in the visibility of the image using dct,” International Journal of Engineering Research and Applica- by applying modification of colors, but the described technique tions, vol. 2, no. 1, pp. 515–521, 2012. [12] C. Rawat and S. Meher, “A hybrid image compression scheme using allows to design an algorithm reverse if the input parameters dct and fractal image compression.” Int. Arab J. Inf. Technol., vol. 10, are known. no. 6, pp. 553–562, 2013. 11 (a) 479KB (b) 173KB (c) 113KB (d) 48,6KB Fig. 5: Examples of quality compression. 12 (a) 188KB (b) 61,6KB (c) 99,7KB (d) 26,9KB (e) 87,4KB (f) 26,3KB Fig. 6: Examples of quality compression. 13 (a) 186KB (b) 63KB Fig. 7: Example of quality compression. [13] T. Anitha and S. Ramachandran, “Novel algorithms for 2-d fft and its inverse for image compression,” in Signal Processing Image Processing & Pattern Recognition (ICSIPR), 2013 International Conference on. IEEE, 2013, pp. 62–65. [14] W. Hu, G. Cheung, A. Ortega, and O. C. Au, “Multiresolution graph fourier transform for compression of piecewise smooth images,” Image Processing, IEEE Transactions on, vol. 24, no. 1, pp. 419–433, 2015. [15] G. Fracastoro, F. Verdoja, M. Grangetto, and E. Magli, “Superpixel- driven graph transform for image compression,” in Image Processing (ICIP), 2015 IEEE International Conference on. IEEE, 2015, pp. 2631– 2635. 14