FLoCIC: A Few Lines of Code for Raster Image Compression
<p>Typical components of the lossless image compression pipeline.</p> "> Figure 2
<p>Pixels used in (<b>a</b>) JPEG LS prediction and (<b>b</b>) for context modeling.</p> "> Figure 3
<p>Example: The matrix contains the values of <math display="inline"><semantics> <mi>ϵ</mi> </semantics></math> after the prediction process.</p> "> Figure 4
<p>Example: (<b>a</b>) A sequence of prediction errors. (<b>b</b>) A sequence of interleaved values. (<b>c</b>) The running sum sequence of cumulative integer values.</p> "> Figure 5
<p>Example: Result of encoding.</p> "> Figure 6
<p>Example: Storing the results of interpolative coding.</p> "> Figure 7
<p>Example of decoding. (<b>a</b>) Situation after initialization. (<b>b</b>) Decoded element at <math display="inline"><semantics> <mrow> <mi>m</mi> <mo>=</mo> <mn>9</mn> </mrow> </semantics></math>.</p> "> Figure 8
<p>Testing raster images.</p> ">
Abstract
:1. Introduction
- An evaluation of a new local pixel prediction model;
- A simplification of interpolative coding;
- Testing the suitability of interpolative coding for continuous-tone image compression;
- Comparison of the proposed data compression approach with PNG, JPEG LS, and JPEG 2000 in lossless mode;
- A compact programming code.
2. Background
- None: ;
- Sub: ;
- Up: };
- Average: ;
- Paeth: .
3. Materials and Methods
3.1. Multifunction Local Predictions
3.2. Interpolative Coding
- A range of all possible values is determined first (see Equation (8)) by taking into account that is strictly monotone:
- The number of bits g needed to encode all possible values from G is then calculated with Equation (9):
- Finally, the value is encoded in binary with g bits and sent to the output , where and are bits and is the total number of bits.
- is obtained from with Equation (10):
- Calculation of guards and is not needed, as the range containing the value is simply .
- Detection of the optimal case is simplified to check whether .
3.2.1. An Example
Algorithm 1 Lossless image compression with FLoCIC |
|
Algorithm 2 JPEG LS prediction |
|
Algorithm 3 Simplified interpolative coding |
|
3.2.2. Decoding
- The values of the first and the last element ;
- The length n;
- The sequence of bits .
Algorithm 4 Image decompression with FLoCIC |
|
Algorithm 5 Simplified interpolative decoding |
|
Algorithm 6 Inverted JPEG LS predictor |
|
4. Experiments
5. Discussion
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Shannon, C.E. A Mathematical Theory of Communication. AT&T Tech. J. 1948, 27, 379–423. [Google Scholar]
- Nelson, M.; Gailly, J.-L. The Data Compression Book, 2nd ed.; M&T Books: New York, NY, USA, 1991. [Google Scholar]
- Moffat, A.; Turpin, A. Compression and Coding Algorithms; Kluwer Academic: New York, NY, USA, 2002. [Google Scholar]
- Cover, T.M.; Thomas, J.A. Elements of Information Theory, 2nd ed.; Wiley: Hoboken, NJ, USA, 2006. [Google Scholar]
- Salomon, D.; Motta, G. Handbook of Data Compression, 5th ed.; Springer: London, UK, 2010. [Google Scholar]
- Sayood, K. Introduction to Data Compression, 4th ed.; Morgan Kaufman: Waltham, MA, USA; Elsevier: Waltham, MA, USA, 2012. [Google Scholar]
- Richardson, I.E.G. H.264 and MPEG-4 Video Compression: Video Coding for Next-Generation Multimedia; Wiley: Chichester, UK, 2003. [Google Scholar]
- Rao, K.R.; Yip, P. Discrete Cosine Transform; Academic Press: Boston, MA, USA, 1990. [Google Scholar]
- Sridhar, S.; Kumar, P.R.; Ramanalah, K.V. Wavelet Transform Techniques for Image Compression—An Evaluation. Int. J. Image Graph. Sig. Process. 2014, 6, 54–67. [Google Scholar] [CrossRef] [Green Version]
- Starosolski, R. Hybrid Adaptive Lossless Image Compression Based on Discrete Wavelet Transform. Entropy 2020, 22, 751. [Google Scholar] [CrossRef]
- Qin, Q.; Liang, Z.; Liu, S.; Wang, X.; Zhou, C. A Dual-Domain Image Encryption Algorithm Based on Hyperchaos and Dynamic Wavelet Decomposition. IEEE Access 2022, 10, 122726–122744. [Google Scholar] [CrossRef]
- Demaret, L.; Dyn, N.; Iske, A. Image compression by linear splines over adaptive triangulations. Signal Process 2020, 22, 1604–1616. [Google Scholar] [CrossRef]
- Papamarkos, N.; Atsalakis, A.E.; Strouthopoulos, C.P. Adaptive color reduction. IEEE Trans. Syst. Man Cybern. 2002, 32, 44–56. [Google Scholar] [CrossRef] [PubMed]
- Jeromel, A.; Žalik, B. An efficient lossy cartoon image compression method. Multimed. Tools Appl. 2020, 79, 433–451. [Google Scholar] [CrossRef] [Green Version]
- Ansari, R.; Momon, N.; Ceran, E. Near-lossless image compression techniques. J. Electron. Imaging 1998, 7, 486–494. [Google Scholar]
- Rahman, M.A.; Hamada, M. Lossless Image Compression Techniques: A State-of-the-Art Survey. Symmetry 2019, 11, 1274. [Google Scholar] [CrossRef] [Green Version]
- Weinberger, M.J.; Seroussi, G.; Sapiro, G. The LOCO-I Lossless Image Compression Algorithm: Principles and Standardization into JPEG-LS. IEEE T Image Process 2000, 9, 1309–1324. [Google Scholar] [CrossRef] [Green Version]
- Xiaolin, W.; Memon, N. Context-based lossless interband compression-extending CALIC. IEEE Trans. Image Process 2000, 9, 994–1001. [Google Scholar] [CrossRef] [PubMed] [Green Version]
- Žalik, B.; Mongus, D.; Lukač, N. Can burrows-Wheeler transform be replaced in chain code compression? Inf. Sci. 2020, 525, 109–118. [Google Scholar] [CrossRef]
- Overview of JPEG LS. Available online: https://jpeg.org/jpegls/index.html (accessed on 23 January 2023).
- Golomb, S.W. Run–length encodings. IEEE Trans. Inform. Theory 1966, 12, 399–401. [Google Scholar] [CrossRef] [Green Version]
- Welch, T. A Technique for High-Performance Data Compression. Computer 1984, 17, 8–19. [Google Scholar] [CrossRef]
- PortableNetwork Graphics. Available online: http://www.libpng.org/pub/png/ (accessed on 23 January 2023).
- Paeth, A.W. Image File Compression Made Easy; Graphics Gems, 2; James, A., Ed.; Academic Press: San Diego, CA, USA, 1991; pp. 93–100. [Google Scholar]
- Ziv, J.; Lempel, A. A universal algorithm for sequential data compression. IEEE Trans. Inf. Theory 1977, 23, 337–343. [Google Scholar] [CrossRef] [Green Version]
- Huffman, D.A. A Method for the Construction of Minimum-Redundancy Codes. Proc. IRE 1952, 40, 1098–1101. [Google Scholar] [CrossRef]
- Taubman, D.; Marcellin, M.W. JPEG2000: Image Compression Fundamentals Standards and Practice; Kluwer: Boston, MA, USA, 2002. [Google Scholar]
- Le Gall, D.; Tabatabai, A.J. Sub-band coding of digital images using symmetric short kernel filters and arithmetic coding techniques. In Proceedings of the ICASSP-88: International Conference on Acoustics, Speech, and Signal Processing, New York, NY, USA, 11–14 April 1988; IEEE Press: Piscataway, NJ, USA, 1988; pp. 761–764. [Google Scholar]
- Ko, H.-H. Enhanced Binary MQ Arithmetic Coder with Look-Up Table. Information 2021, 12, 143. [Google Scholar] [CrossRef]
- Ulacha, G.; Łazoryszczak, M. Lossless Image Coding Using Non-MMSE Algorithms to Calculate Linear Prediction Coefficients. Entropy 2023, 25, 156. [Google Scholar] [CrossRef]
- Moffat, A.; Stuiver, L. Binary interpolative coding for effective index compression. Inf. Retr. 2000, 3, 25–47. [Google Scholar] [CrossRef]
- Žalik, B.; Mongus, D.; Lukač, N.; Rizman Žalik, K. Efficient chain code compression with interpolative coding. Inf. Sci. 2018, 439, 39–49. [Google Scholar] [CrossRef]
- Žalik, B.; Rizman Žalik, K.; Zupančič, E.; Lukač, N.; Žalik, M.; Mongus, D. Chain code compression with modified interpolative coding. Comput. Electr. Eng. 2019, 77, 27–36. [Google Scholar] [CrossRef]
- Howard, P.G.; Vitter, J. Fast and efficient lossless image compression. In Proceedings of the DC’93: Data Compression Conference, Snowbird, UT, USA, 30 March–2 April 1993; IEEE Computer Society: New York, NY, USA, 1993; pp. 208–215. [Google Scholar]
- Niemi, A.; Teuhola, J. Interpolative coding as an alternative to arithmetic coding in bi-level image compression. In Proceedings of the SCC 2015—10th International ITG Conference on Systems, Communications and Coding, Hamburg, Germany, 2–5 May 2015; IEEE: New York, NY, USA, 2015; pp. 1–6. [Google Scholar]
- Strnad, D.; Kohek, Š.; Nerat, A.; Žalik, B. Efficient representation of geometric tree models with level-of-detail using compressed 3D chain code. IEEE Trans. Vis. Comput. Graph. 2020, 26, 3177–3188. [Google Scholar] [CrossRef] [PubMed]
- FLoCIC. Available online: https://github.com/mitzal/FLoCIC (accessed on 14 March 2023).
- IrfanView. Available online: https://www.irfanview.com/ (accessed on 23 January 2023).
- ImageMagick. Available online: https://imagemagick.org/ (accessed on 23 January 2023).
- Bodden, E.; Clasen, M.; Kneis, J. Arithmetic Coding Revealed; Sable Technical Report No. 2007-5; McGill University: Montreal, QC, Canada, 2007. [Google Scholar]
- Marpe, D.; Scwarz, H.; Wiegand, T. Context-Based Adaptive Binary Arithmetic Coding in the H.264/AVC Video Compression Standard. IEEE Trans. Circuits Syst. Video Technol. 2003, 13, 620–636. [Google Scholar] [CrossRef] [Green Version]
- Overview of JPEG XL. Available online: https://jpeg.org/jpegxl/ (accessed on 23 January 2023).
- An Image Format for Web. Available online: https://developers.google.com/speed/webp/ (accessed on 23 January 2023).
- Globačnik, T.; Žalik, B. An efficient raster font compression for embedded systems. Pattern Recogn. 2010, 43, 4137–4147. [Google Scholar] [CrossRef]
- Špelič, D.; Novak, F.; Žalik, B. Educational support for computational geometry course—The Delaunay triangulation tester. Int. J. Eng. Educ. 2009, 25, 93–101. [Google Scholar]
- Krivograd, S.; Žalik, B.; Novak, F. TriMeDeC tool for preparing visual teaching materials based on triangular networks. Comput. Appl. Eng. Educ. 2002, 10, 144–154. [Google Scholar] [CrossRef]
L | H | m | 1 | g | v 2 | Code | |
---|---|---|---|---|---|---|---|
0 | 19 | 9 | 35 | [23, 63] | 6 | 12 | 001100 |
0 | 9 | 4 | 35 | [23, 35] | 4 | 12 | 1100 |
0 | 4 | 2 | 26 | [23, 35] | 4 | 3 | 0011 |
0 | 2 | 1 | 24 | [23, 26] | 2 | 1 | 01 |
4 | 9 | / | / | [35, 35] | / | / | / 3 |
9 | 19 | 14 | 54 | [35, 63] | 5 | 19 | 10011 |
9 | 14 | 11 | 43 | [35, 54] | 5 | 8 | 01000 |
9 | 11 | 10 | 35 | [35, 43] | 4 | 0 | 0000 |
11 | 14 | 12 | 46 | [43, 54] | 4 | 3 | 0011 |
12 | 14 | 13 | 52 | [46, 54] | 4 | 6 | 0110 |
14 | 19 | 16 | 54 | [54, 63] | 4 | 0 | 0000 |
14 | 16 | / | / | [54, 54] | / | / | / 3 |
16 | 19 | 17 | 61 | [54, 63] | 4 | 7 | 0111 |
17 | 19 | 18 | 61 | [61, 63] | 2 | 0 | 00 |
Image | Resolution | Raw Size | 1 | 2 | 3 | 4 | |
---|---|---|---|---|---|---|---|
Baboon | 262,144 | 7.357 | 6.499 | 6.414 | 6.275 | 14.342 | |
Balloon | 414,720 | 7.346 | 3.282 | 3.204 | 3.120 | 1.608 | |
Barbara | 262,144 | 7.343 | 5.794 | 5.890 | 5.758 | 12.031 | |
Barb2 | 414,720 | 7.484 | 5.490 | 5.238 | 5.181 | 6.895 | |
Board | 414,720 | 6.828 | 4.073 | 4.013 | 3.947 | 2.927 | |
Boats | 414,720 | 7.088 | 4.527 | 4.394 | 4.307 | 3.707 | |
Cameraman | 65,536 | 6.904 | 5.200 | 5.273 | 5.150 | 8.214 | |
Flower | 245,760 | 7.410 | 3.881 | 3.889 | 3.866 | 2.755 | |
Fruits | 245,760 | 7.366 | 4.173 | 4.170 | 4.014 | 3.062 | |
Girl | 414,720 | 7.288 | 4.354 | 4.153 | 4.207 | 3.391 | |
Gold | 414,720 | 7.530 | 4.959 | 4.951 | 4.716 | 4.716 | |
Hotel | 414,720 | 7.546 | 4.861 | 4.854 | 4.732 | 4.987 | |
Lena | 262,144 | 7.348 | 4.374 | 4.467 | 4.342 | 3.849 | |
Malamute | 1,745,280 | 7.792 | 4.783 | 4.714 | 4.620 | 4.711 | |
Man | 1,048,576 | 7.524 | 5.058 | 5.084 | 4.936 | 5.711 | |
Monarch | 393,216 | 7.18 | 4.143 | 4.1442 | 4.095 | 3.887 | |
Mushrooms | 154,401 | 7.585 | 5.129 | 5.161 | 5.067 | 8.078 | |
Parrots | 393,216 | 7.256 | 3.945 | 3.988 | 3.828 | 2.884 | |
Pens | 245,760 | 7.482 | 4.368 | 4.268 | 4.188 | 3.393 | |
Peppers | 262,144 | 7.594 | 4.828 | 4.859 | 4.942 | 5.747 | |
Rainier | 2,073,600 | 7.088 | 4.499 | 4.466 | 4.298 | 7.699 | |
Sun | 4,271,400 | 6.950 | 3.295 | 3.577 | 2.736 | 1.274 | |
Yachts | 245,760 | 7.560 | 4.369 | 4.302 | 4.148 | 3.423 | |
Zelda | 414,720 | 7.334 | 4.265 | 4.127 | 4.112 | 3.226 | |
Average | 4.646 | 4.666 | 4.516 |
Image | JPEG LS | JPEG 2000 | PNG | FLoCIC-IC | FLoCIC-AC | |||||
---|---|---|---|---|---|---|---|---|---|---|
Size 1 | bpp | Size 1 | bpp | Size 1 | bpp | Size 1 | bpp | Size 1 | bpp | |
Baboon | 196,391 | 5.99 | 200,243 | 6.11 | 203,848 | 6.22 | 206,403 | 6.30 | 206,500 | 6.30 |
Balloon | 149,322 | 2.88 | 157,296 | 3.03 | 177,426 | 3.42 | 170,141 | 3.28 | 162,094 | 3.13 |
Barbara | 165,590 | 5.05 | 168,083 | 5.13 | 186,008 | 5.68 | 178,745 | 5.46 | 189,943 | 5.80 |
Barb2 | 241,027 | 4.65 | 248,400 | 4.79 | 266,756 | 5.15 | 265,877 | 5.13 | 269,352 | 5.20 |
Board | 188,814 | 4.65 | 195,656 | 4.79 | 208,722 | 5.15 | 213,550 | 5.13 | 205,134 | 5.20 |
Boats | 202,388 | 3.90 | 210,879 | 4.07 | 224,294 | 4.33 | 226,595 | 4.37 | 223,740 | 4.32 |
Cam. | 38,137 | 4.66 | 40,850 | 4.99 | 42,403 | 5.18 | 41,142 | 5.02 | 43,310 | 5.29 |
Flower | 106,946 | 3.48 | 108,459 | 3.53 | 124,291 | 4.05 | 120,787 | 3.93 | 119,130 | 3.88 |
Fruits | 113,000 | 3.68 | 114,440 | 3.73 | 129,596 | 4.22 | 123,800 | 4.03 | 123,770 | 4.03 |
Girl | 201,917 | 3.90 | 210,696 | 4.06 | 224,736 | 4.34 | 226,619 | 4.37 | 218,513 | 4.22 |
Gold | 230,562 | 4.45 | 238,785 | 4.61 | 243,019 | 4.69 | 249,535 | 4.81 | 245,006 | 4.73 |
Hotel | 225,316 | 4.35 | 237,861 | 4.59 | 248,916 | 4.80 | 248,076 | 4.79 | 246,013 | 4.75 |
Lena | 130,704 | 4.00 | 134,417 | 4.10 | 145,634 | 4.44 | 143,259 | 4.37 | 142,789 | 4.36 |
Malamut | 2,234,680 | 4.14 | 2,225,757 | 4.06 | 2,394,883 | 4.65 | 2,467,192 | 4.43 | 2,295,195 | 4.62 |
Man | 611,909 | 4.67 | 632,163 | 4.82 | 650,599 | 4.96 | 658,921 | 5.03 | 649,298 | 4.95 |
Monarch | 180,141 | 3.67 | 187,507 | 3.82 | 208,813 | 4.25 | 202,592 | 4.12 | 202,121 | 4.11 |
Mush. | 84,815 | 4.40 | 87,818 | 4.55 | 98,581 | 5.11 | 91,161 | 4.72 | 98,716 | 5.12 |
Parrots | 170,184 | 3.46 | 172,913 | 3.52 | 193,340 | 3.93 | 190,019 | 3.87 | 188,968 | 3.85 |
Pens | 119,155 | 3.88 | 121,308 | 3.95 | 133,358 | 4.34 | 130,957 | 4.26 | 129,120 | 4.20 |
Peppers | 146,630 | 4.48 | 151,739 | 4.63 | 160,465 | 4.90 | 166,822 | 5.01 | 162,562 | 4.96 |
Rainier | 878,701 | 3.39 | 891,800 | 3.44 | 933,263 | 3.60 | 890,090 | 3.43 | 1,115,931 | 4.30 |
Sun | 1,336,035 | 2.50 | 1,727,103 | 3.24 | 1,595,790 | 2.99 | 1,499,305 | 2.81 | 1,463,057 | 2.74 |
Yachts | 115,183 | 3.75 | 120,225 | 3.91 | 132,198 | 4.30 | 126,798 | 4.13 | 127,960 | 4.17 |
Zelda | 200,142 | 3.86 | 201,273 | 3.88 | 214,799 | 4.14 | 226,216 | 4.36 | 213,569 | 4.12 |
Average | 4.03 | 4.18 | 4.49 | 4.43 | 4.46 |
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. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Žalik, B.; Strnad, D.; Kohek, Š.; Kolingerová, I.; Nerat, A.; Lukač, N.; Lipuš, B.; Žalik, M.; Podgorelec, D. FLoCIC: A Few Lines of Code for Raster Image Compression. Entropy 2023, 25, 533. https://doi.org/10.3390/e25030533
Žalik B, Strnad D, Kohek Š, Kolingerová I, Nerat A, Lukač N, Lipuš B, Žalik M, Podgorelec D. FLoCIC: A Few Lines of Code for Raster Image Compression. Entropy. 2023; 25(3):533. https://doi.org/10.3390/e25030533
Chicago/Turabian StyleŽalik, Borut, Damjan Strnad, Štefan Kohek, Ivana Kolingerová, Andrej Nerat, Niko Lukač, Bogdan Lipuš, Mitja Žalik, and David Podgorelec. 2023. "FLoCIC: A Few Lines of Code for Raster Image Compression" Entropy 25, no. 3: 533. https://doi.org/10.3390/e25030533