f885353284af1abf02a854d0d889b4096ed9d6a8
[imagesqueeze.git] / doc / index.org
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;}
10 #+HTML_HEAD: </style>
11
12 * General
13
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.
18
19 - Program author:
20   - Svjatoslav Agejenko
21   - Homepage: http://svjatoslav.eu
22   - Email: mailto://svjatoslav@svjatoslav.eu
23
24 - [[http://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]]
25
26 ** Source code
27 - [[http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]]
28
29 - [[http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=summary][Browse Git repository online]]
30
31 - Clone Git repository using command:
32   : git clone http://www2.svjatoslav.eu/git/imagesqueeze.git
33
34 * Overview
35 Lossy image codec. Optimized for photos. I developed it to test out an
36 image compression ideas.
37
38 I believe my [[id:1d917f74-e763-4a71-976e-4aa60732efa6][algorighm has interesting advantages.]]
39
40 Below are original photo and the same image being compressed down to
41 ~93 Kb and then decompressed.
42
43 [[file:originalAndCompressed.png][file:originalAndCompressed.png]]
44
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.
53
54 + Single channel compression method:
55
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.
58
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
65     difference.
66 ** Algorighm advantages
67    :PROPERTIES:
68    :ID:       1d917f74-e763-4a71-976e-4aa60732efa6
69    :END:
70 + It can be applied to any amount of dimensions, even for sound and
71   volumetric data.
72
73 + Algorithm can operate in lossy and lossless mode.
74
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.
78
79 + Algorithm naturally supports variable resolution. That is: different
80   areas can be encoded with different resolutions / pixel densities.
81
82 + Fast: Very little computations per pixel.
83
84 * TODO Things to improve
85 - Code documentation is weak.
86
87 - Better sample applications needed:
88   - Commandline image conversion utility.
89   - Image viewer.
90
91 - Add lossless support.
92
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.