83164f31db161c0b018f04c2292b4d66b155d47f
[imagesqueeze.git] / doc / index.org
1 #+TITLE: ImageSqueeze - lossy image codec
2
3 -----
4 - [[http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=snapshot;h=HEAD;sf=tgz][download latest snapshot]]
5
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.
9
10 - Program author:
11   - Svjatoslav Agejenko
12   - Homepage: http://svjatoslav.eu
13   - Email: mailto://svjatoslav@svjatoslav.eu
14
15 - [[http://www.svjatoslav.eu/programs.jsp][other applications hosted at svjatoslav.eu]]
16
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;}
25 #+HTML_HEAD: </style>
26
27 * Overview
28 Lossy image codec. Optimized for photos. I developed it to test out an
29 image compression ideas.
30
31 I believe my [[id:1d917f74-e763-4a71-976e-4aa60732efa6][algorighm has interesting advantages.]]
32
33 Below are original photo and the same image being compressed down to
34 ~93 Kb and then decompressed.
35
36 [[file:originalAndCompressed.png][file:originalAndCompressed.png]]
37
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.
46
47 + Single channel compression method:
48
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.
51
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
58     difference.
59 ** Algorighm advantages
60    :PROPERTIES:
61    :ID:       1d917f74-e763-4a71-976e-4aa60732efa6
62    :END:
63 + It can be applied to any amount of dimensions, even for sound and
64   volumetric data.
65
66 + Algorithm can operate in lossy and lossless mode.
67
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.
71
72 + Algorithm naturally supports variable resolution. That is: different
73   areas can be encoded with different resolutions / pixel densities.
74
75 + Fast: Very little computations per pixel.
76
77 * TODO Things to improve
78 - Code documentation is weak.
79
80 - Better sample applications needed:
81   - Commandline image conversion utility.
82   - Image viewer.
83
84 - Add lossless support.
85
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.