1 #+TITLE: ImageSqueeze - lossy image codec
2 * (document settings) :noexport:
3 ** use dark style for TWBS-HTML exporter
4 #+HTML_HEAD: <link href="https://bootswatch.com/3/darkly/bootstrap.min.css" rel="stylesheet">
5 #+HTML_HEAD: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
6 #+HTML_HEAD: <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
7 #+HTML_HEAD: <style type="text/css">
8 #+HTML_HEAD: footer {background-color: #111 !important;}
9 #+HTML_HEAD: pre {background-color: #111; color: #ccc;}
14 - This program is free software: you can redistribute it and/or modify
15 it under the terms of the [[https://www.gnu.org/licenses/lgpl.html][GNU Lesser General Public License]] as
16 published by the Free Software Foundation, either version 3 of the
17 License, or (at your option) any later version.
21 - Homepage: http://svjatoslav.eu
22 - Email: mailto://svjatoslav@svjatoslav.eu
24 - [[http://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]]
27 - [[http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]]
29 - [[http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=summary][Browse Git repository online]]
31 - Clone Git repository using command:
32 : git clone http://www2.svjatoslav.eu/git/imagesqueeze.git
35 Lossy image codec. Optimized for photos. I developed it to test out an
36 image compression ideas.
38 I believe my [[id:1d917f74-e763-4a71-976e-4aa60732efa6][algorighm has interesting advantages.]]
40 Below are original photo and the same image being compressed down to
41 ~93 Kb and then decompressed.
43 [[file:originalAndCompressed.png][file:originalAndCompressed.png]]
45 When looking very closely, slight grainyness, loss of color precision
46 and blurriness (loss of detail) could be noticed as a compression
47 artifacts. Still sharp edges are always preserved. Also no blocks
48 typical to JPEG are ever seen. I think that is awesome result for
49 just ~ 2.5 bits per pixel on that color photo.
50 * Algorithm description
51 + Color image is split into three separate channels: Y, U and V.
52 + Each channel is independently compressed.
54 + Single channel compression method:
56 + Algorithm is inspired by [[https://en.wikipedia.org/wiki/Diamond-square_algorithm][diamond-square algorithm]] that is meant to
57 produce random heightmap/plasma effect.
59 + During image compression: 2D image surface is iterated in the
60 similar manner to diamond-square algorithm. Average color from
61 neighbors is calculated and difference between neighbors average
62 and actual pixel color is saved. As the pixel grid becomes
63 gradually more dense, difference between neighbors tends to get
64 smaller, thereby requiring less bits per pixel for storing the
66 ** Algorighm advantages
68 :ID: 1d917f74-e763-4a71-976e-4aa60732efa6
70 + It can be applied to any amount of dimensions, even for sound and
73 + Algorithm can operate in lossy and lossless mode.
75 + Algorithm naturally handles progressive loading. That is: low
76 resolution thumbnail of entire thing is immediately available and
77 gets gradually more dense during entire loading process.
79 + Algorithm naturally supports variable resolution. That is: different
80 areas can be encoded with different resolutions / pixel densities.
82 + Fast: Very little computations per pixel.
84 * TODO Things to improve
85 - Code documentation is weak.
87 - Better sample applications needed:
88 - Commandline image conversion utility.
91 - Add lossless support.
93 - Extract algorithm key parts into reusable library and make it
94 variable dimensional. So that the same code can be used for sound,
95 image and volumetric data compression/decompression.