ImageSqueeze - lossy image codec
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- Program author:
- Other software projects hosted at svjatoslav.eu
Lossy image codec. Optimized for photos. I developed it to test out an image compression ideas.
I believe my algorighm has interesting advantages.
Below are original photo and the same image being compressed down to ~93 Kb and then decompressed.
When looking very closely, slight grainyness, loss of color precision and blurriness (loss of detail) could be noticed as a compression artifacts. Still sharp edges are always preserved. Also no blocks typical to JPEG are ever seen. I think that is awesome result for just ~ 2.5 bits per pixel on that color photo.
3 Algorithm description
- Color image is split into three separate channels: Y, U and V.
- Each channel is independently compressed.
- Single channel compression method:
- Algorithm is inspired by diamond-square algorithm that is meant to produce random heightmap/plasma effect.
- During image compression: 2D image surface is iterated in the similar manner to diamond-square algorithm. Average color from neighbors is calculated and difference between neighbors average and actual pixel color is saved. As the pixel grid becomes gradually more dense, difference between neighbors tends to get smaller, thereby requiring less bits per pixel for storing the difference.
- It can be applied to any amount of dimensions, even for sound and volumetric data.
- Algorithm can operate in lossy and lossless mode.
- Algorithm naturally handles progressive loading. That is: low resolution thumbnail of entire thing is immediately available and gets gradually more dense during entire loading process.
- Algorithm naturally supports variable resolution. That is: different areas can be encoded with different resolutions / pixel densities.
- Fast: Very little computations per pixel.
4 TODO Things to improve
- Code documentation is weak.
- Better sample applications needed:
- Commandline image conversion utility.
- Image viewer.
- Add lossless support.
- Extract algorithm key parts into reusable library and make it variable dimensional. So that the same code can be used for sound, image and volumetric data compression/decompression.