4 <title>ImageSqueeze - lossy image codec</title>
5 <!-- 2018-06-24 Sun 03:17 -->
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <meta name="generator" content="Org-mode">
9 <meta name="author" content="Svjatoslav Agejenko">
10 <link href="https://bootswatch.com/3/darkly/bootstrap.min.css" rel="stylesheet">
11 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
12 <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
13 <style type="text/css">
14 footer {background-color: #111 !important;}
15 pre {background-color: #111; color: #ccc;}
17 <style type="text/css">
18 /* org mode styles on top of twbs */
35 background-color: #f5f5f5;
62 display: inline-block;
74 .bs-docs-sidebar.affix {
77 @media (min-width: 768px) {
83 /* All levels of nav */
84 .bs-docs-sidebar .nav > li > a {
91 .bs-docs-sidebar .nav > li > a:hover,
92 .bs-docs-sidebar .nav > li > a:focus {
95 text-decoration: none;
96 background-color: transparent;
97 border-left: 1px solid #A1283B;
99 .bs-docs-sidebar .nav > .active > a,
100 .bs-docs-sidebar .nav > .active:hover > a,
101 .bs-docs-sidebar .nav > .active:focus > a {
105 background-color: transparent;
106 border-left: 2px solid #A1283B;
109 /* Nav: second level (shown on .active) */
110 .bs-docs-sidebar .nav .nav {
111 display: none; /* Hide by default, but at >768px, show it */
112 padding-bottom: 10px;
114 .bs-docs-sidebar .nav .nav > li > a {
121 .bs-docs-sidebar .nav .nav > li > a:hover,
122 .bs-docs-sidebar .nav .nav > li > a:focus {
125 .bs-docs-sidebar .nav .nav > .active > a,
126 .bs-docs-sidebar .nav .nav > .active:hover > a,
127 .bs-docs-sidebar .nav .nav > .active:focus > a {
132 /* Nav: third level (shown on .active) */
133 .bs-docs-sidebar .nav .nav .nav {
134 padding-bottom: 10px;
136 .bs-docs-sidebar .nav .nav .nav > li > a {
143 .bs-docs-sidebar .nav .nav .nav > li > a:hover,
144 .bs-docs-sidebar .nav .nav .nav > li > a:focus {
147 .bs-docs-sidebar .nav .nav .nav > .active > a,
148 .bs-docs-sidebar .nav .nav .nav > .active:hover > a,
149 .bs-docs-sidebar .nav .nav .nav > .active:focus > a {
154 /* Show and affix the side nav when space allows it */
155 @media (min-width: 992px) {
156 .bs-docs-sidebar .nav > .active > ul {
159 /* Widen the fixed sidebar */
160 .bs-docs-sidebar.affix,
161 .bs-docs-sidebar.affix-bottom {
164 .bs-docs-sidebar.affix {
165 position: fixed; /* Undo the static from mobile first approach */
168 .bs-docs-sidebar.affix-bottom {
169 position: absolute; /* Undo the static from mobile first approach */
171 .bs-docs-sidebar.affix .bs-docs-sidenav,.bs-docs-sidebar.affix-bottom .bs-docs-sidenav {
176 @media (min-width: 1200px) {
177 /* Widen the fixed sidebar again */
178 .bs-docs-sidebar.affix-bottom,
179 .bs-docs-sidebar.affix {
184 <script type="text/javascript">
188 $('.bs-docs-sidebar li').first().addClass('active');
190 $(document.body).scrollspy({target: '.bs-docs-sidebar'});
192 $('.bs-docs-sidebar').affix();
197 <div id="content" class="container">
198 <div class="row"><div class="col-md-9"><h1 class="title">ImageSqueeze - lossy image codec</h1>
199 <div id="outline-container-sec-1" class="outline-2">
200 <h2 id="sec-1"><span class="section-number-2">1</span> General</h2>
201 <div class="outline-text-2" id="text-1">
203 <li>This program is free software: you can redistribute it and/or modify
204 it under the terms of the <a href="https://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License</a> as
205 published by the Free Software Foundation, either version 3 of the
206 License, or (at your option) any later version.
211 <li>Svjatoslav Agejenko
213 <li>Homepage: <a href="http://svjatoslav.eu">http://svjatoslav.eu</a>
215 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a>
220 <li><a href="http://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a>
225 <div id="outline-container-sec-1-1" class="outline-3">
226 <h3 id="sec-1-1"><span class="section-number-3">1.1</span> Source code</h3>
227 <div class="outline-text-3" id="text-1-1">
229 <li><a href="http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=snapshot;h=HEAD;sf=tgz">Download latest snapshot in TAR GZ format</a>
232 <li><a href="http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=summary">Browse Git repository online</a>
235 <li>Clone Git repository using command:
236 <pre class="example">
237 git clone http://www2.svjatoslav.eu/git/imagesqueeze.git
245 <div id="outline-container-sec-2" class="outline-2">
246 <h2 id="sec-2"><span class="section-number-2">2</span> Overview</h2>
247 <div class="outline-text-2" id="text-2">
249 Lossy image codec. Optimized for photos. I developed it to test out an
250 image compression ideas.
254 I believe my <a href="#sec-3-1">algorighm has interesting advantages.</a>
258 Below are original photo and the same image being compressed down to
259 ~93 Kb and then decompressed.
264 <p><a href="originalAndCompressed.png"><img src="originalAndCompressed.png" class="img-responsive" alt="originalAndCompressed.png"></a>
269 When looking very closely, slight grainyness, loss of color precision
270 and blurriness (loss of detail) could be noticed as a compression
271 artifacts. Still sharp edges are always preserved. Also no blocks
272 typical to JPEG are ever seen. I think that is awesome result for
273 just ~ 2.5 bits per pixel on that color photo.
277 <div id="outline-container-sec-3" class="outline-2">
278 <h2 id="sec-3"><span class="section-number-2">3</span> Algorithm description</h2>
279 <div class="outline-text-2" id="text-3">
281 <li>Color image is split into three separate channels: Y, U and V.
283 <li>Each channel is independently compressed.
288 <li>Single channel compression method:
291 <li>Algorithm is inspired by <a href="https://en.wikipedia.org/wiki/Diamond-square_algorithm">diamond-square algorithm</a> that is meant to
292 produce random heightmap/plasma effect.
295 <li>During image compression: 2D image surface is iterated in the
296 similar manner to diamond-square algorithm. Average color from
297 neighbors is calculated and difference between neighbors average
298 and actual pixel color is saved. As the pixel grid becomes
299 gradually more dense, difference between neighbors tends to get
300 smaller, thereby requiring less bits per pixel for storing the
307 <div id="outline-container-sec-3-1" class="outline-3">
308 <h3 id="sec-3-1"><a id="ID-1d917f74-e763-4a71-976e-4aa60732efa6" name="ID-1d917f74-e763-4a71-976e-4aa60732efa6"></a><span class="section-number-3">3.1</span> Algorighm advantages</h3>
309 <div class="outline-text-3" id="text-3-1">
311 <li>It can be applied to any amount of dimensions, even for sound and
315 <li>Algorithm can operate in lossy and lossless mode.
318 <li>Algorithm naturally handles progressive loading. That is: low
319 resolution thumbnail of entire thing is immediately available and
320 gets gradually more dense during entire loading process.
323 <li>Algorithm naturally supports variable resolution. That is: different
324 areas can be encoded with different resolutions / pixel densities.
327 <li>Fast: Very little computations per pixel.
334 <div id="outline-container-sec-4" class="outline-2">
335 <h2 id="sec-4"><span class="section-number-2">4</span> <span class="label label-primary TODO">TODO</span> Things to improve</h2>
336 <div class="outline-text-2" id="text-4">
338 <li>Code documentation is weak.
341 <li>Better sample applications needed:
343 <li>Commandline image conversion utility.
350 <li>Add lossless support.
353 <li>Extract algorithm key parts into reusable library and make it
354 variable dimensional. So that the same code can be used for sound,
355 image and volumetric data compression/decompression.
360 </div><div class="col-md-3"><nav id="table-of-contents">
361 <div id="text-table-of-contents" class="bs-docs-sidebar">
363 <li><a href="#sec-1">1. General</a>
365 <li><a href="#sec-1-1">1.1. Source code</a></li>
368 <li><a href="#sec-2">2. Overview</a></li>
369 <li><a href="#sec-3">3. Algorithm description</a>
371 <li><a href="#sec-3-1">3.1. Algorighm advantages</a></li>
374 <li><a href="#sec-4">4. Things to improve</a></li>
379 <footer id="postamble" class="">
380 <div><p class="author">Author: Svjatoslav Agejenko</p>
381 <p class="date">Created: 2018-06-24 Sun 03:17</p>
382 <p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.1.1 (<a href="http://orgmode.org">Org-mode</a> 8.2.10)</p>