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