[babl] docs: update



commit 8c0d1a942a4010b136f41b05cda45421b73d80da
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jun 19 13:20:43 2019 +0200

    docs: update

 TODO                         |   7 +++
 docs/index-static.html.in    | 109 +++++++++++++++++++++++++++++++------------
 tests/transparent_symmetry.c |  26 ++++++-----
 3 files changed, 99 insertions(+), 43 deletions(-)
---
diff --git a/TODO b/TODO
index 2dbb27a..b83bb34 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,12 @@
 <h2>TODO</h2>
 
+<p>These are among desired or expected changes to babl, that are missing.</p>
+
 <ul>
+  <li>extensions for many SIMD variants for many archiectures.</li>
+  <li>Spectral pixel formats - with configurable spectral mapping to tristimulus with configurable 
illuminant + observer</li>
+  <li>Spectral substrate + ink/paint job configuration as a pixel format,
+combined with above to achieve soft proofing, and stochastic sparse LUT for
+separation.</li>
   <li>Support for datatypes that are not a multiple of 8bit.</li>
 </ul>
diff --git a/docs/index-static.html.in b/docs/index-static.html.in
index 9f9a08f..207a620 100644
--- a/docs/index-static.html.in
+++ b/docs/index-static.html.in
@@ -71,6 +71,9 @@
       <ul>
         <li><a href='#Babl'>Babl</a></li>
         <li><a href='#Features'>&nbsp;&nbsp;Features</a></li>
+        <li><a href='#Symmetric-Alpha'>&nbsp;&nbsp;Symmetric-Alpha</a></li>
+        <li><a href='#CMYK'>&nbsp;&nbsp;CMYK</a></li>
+        <li><a href='#ColorManagement'>&nbsp;&nbsp;Color Management</a></li>
         <li><a href='#Download'>Download</a></li>
         <!--<li><a href='#Background'>Background</a></li>-->
         <li><a href='#Documentation'>Documentation</a></li>
@@ -118,14 +121,17 @@
       <li>Stable, small API, with singleton objects returned.</li>
       <li>Extendable with new formats, color models, components
       and datatypes.</li>
-      <li>Can load color spaces from ICC v2 and v4 profiles containing RGB
-          matrix + TRC, or CMYK profiles.</li>
+        <li>Can load <a href='#ColorManagement'>&nbsp;&nbsp;Color
+Spaces</a></li> rom ICC v2 and v4 profiles containing RGB matrix + TRC, or <a
+href='#CMYK'>CMYK</a> profiles.</li>
+      <li><a href='#Symmetric-Alpha'>Symmetric-Alpha</a> no loss of color fidelity due to asymptotic 
behavior near alpha 0.0 in floating point.</li>
       <li>Reference 64bit floating point conversions for datatypes and color
           models, with 32bit floating point reference speed-ups in some places.
       </li>
       <li>Self profiling/validating and optimizing, optimizing accuracy and
 performance at runtime when the best performing single or multi-step conversion
-path is chosen.</li>
+path is chosen. This permits additional SIMD optimiations paths to be added and
+to ones supported are competing with each other.</li>
     </ul>
 
     <p><a href='http://www.gegl.org/'>GEGL</a> through <a
@@ -171,18 +177,17 @@ path is chosen.</li>
 
     <p>When performing further extensions to the vocabulary of babl, the
     internal consistency is governed by reference conversions that operate
-    on <em>double</em> (64 bit floating point values). The only color model
-    created during BablCore bootstrap is <em>RGBA</em> (linear light RGB,
-    0.0 - 1.0, with a linear 0.0 - 1.0 opacity channel) backed by the
-    <em>double</em> datatype. Defined similarily to <a
+    on <em>double</em> (64 bit floating point values). Color Spaces can
+    be created from chromaticity coordinates or ICC profiles. The reference
+    color space - to maintain fast and bit-accurate conversions on with
+    sRGB is similar to <a
     href='http://en.wikipedia.org/wiki/ScRGB_color_space'>scRGB</a> using
     64bit floating point.
     </p>
 
-    <p>If babls conversion isn't fast enough, you can provide
-    your own conversion shortcut between two formats. The registered
-    shortcut might also be used by babl as an intermediate conversion when
-    constructing BablFishes for other conversions.
+    <p>To speed up operations, ffast path conversions are used.
+    The registered shortcut might also be used by babl as an intermediate
+conversion when constructing BablFishes for other conversions.
     </p>
 
     <p>Babl extensions are shared objects. If you have already developed
@@ -276,7 +281,68 @@ spaces, as they are defined with constants on their wikipedia pages or similar u
   a babl format can also be queried with babl_format_get_space.
   </p>
 
-  <a name='cmyk'></a>
+  <a name='Symmetric-Alpha'></a>
+  <h2>Symmetric transformations for floating point alpha</h2>
+
+
+  <p>
+  babl clamps the alpha used when going from separate alpha to associated alpha
+or from associated alpha to separate alpha to BABL_ALPHA_FLOOR. This avoids
+asymptotic behavior and direct precision loss of color precision when multiplying or dividing by alphas near 
0.0.</p>
+
+<p>Original intent of data as well as non-asymptotic precision loss is thus
+maintained when the processing chain might temporarily use the other alpha
+representation.</p>
+
+<pre>
+    #define BABL_ALPHA_FLOOR    (1.0/65536.0)
+    #define BABL_ALPHA_FLOOR_F  (1.0f/65536.0f)
+</pre>
+
+<p>The deviation from not clamping near 0.0 is within the quantization margin
+of 16bit integer alpha, thus no adaptations of are introduced for the 8bit and 16bit versions of pixel 
format conversions were needed.
+  </p>
+
+   <p>This is the clamping function:</p>
+<pre>
+
+    static inline float
+    babl_epsilon_for_zero_float (float value)
+    {
+     if (value &lt;= BABL_ALPHA_FLOOR_F)
+     {
+       /* for performance one could directly retun BABL_ALPHA_FLOOR_F here
+          and dropping handling negative values consistently. */
+       if (value &gt;= 0.0f)
+         return BABL_ALPHA_FLOOR_F;
+       else if (value &gt;= -BABL_ALPHA_FLOOR_F)
+         return -BABL_ALPHA_FLOOR_F;
+     }
+     return value;  /* most common case, return input value */
+    }
+</pre>
+<p>And an example use of this clamping function that is consistent with babls behavior:</p>
+<pre>
+    static inline void
+    associated_to_separate_rgba (const float *associated_rgba,
+                                       float *separate_rgba)
+    {
+      float alpha = associated_rgba[3];
+      float clamped_alpha = babl_epsilon_for_zero_float (alpha);
+      float reciprocal_alpha = 1.0f / clamped_alpha;
+
+      separate_rgba[0] = associated_rgba[0] * reciprocal_alpha;
+      separate_rgba[1] = associated_rgba[1] * reciprocal_alpha;
+      separate_rgba[2] = associated_rgba[2] * reciprocal_alpha;
+      separate_rgba[3] = alpha;
+    }
+</pre>
+
+
+<p>For more detils see <a 
href='https://gitlab.gnome.org/GNOME/babl/commit/a4d607843d3cab18745d547fc8a46dec51dcea5e'>the commit message 
of the most recent refinement</a> as well as <a 
href='https://www.patreon.com/posts/premultiplied-in-21014115'>blog post with further background</a>.</p>
+
+
+  <a name='CMYK'></a>
   <h2>CMYK</h2>
 
   <p>CMYK handling is done using babl-spaces created with ICC profiles
@@ -370,25 +436,6 @@ and float:</p>
         -->
 
 
-  <a name='premultiplied-alpha'></a>
-  <h2>Pre-multiplied alpha</h2>
-
-  <p>babl stores color information in transparent pre-multiplied or associated
-alpha pixels in floating point formats. With floating point pixel formats
-standard way of handling alpha maintains color information very near fully
-transparent pixels - by introducing a limit: BABL_ALPHA_FLOOR which is
-1/65536.0, and treating all alphas beteen zero and this value as this value we
-maintain color information while the discrepancy in behavior gets concealed by
-quantization in 16bit and 8bit formats.
-   </p>
-<p>For images that already are in a premultiplied format on import, this change
-has no impact on its use for pre-multiplied arithmetic, meaning that
-superluminous colors are still supported, it also opens up to GEGL more widely
-expect premultiplied data in more operations which will become a speedup when
-more filters want to integrate in the layer processing pipeline.</p>
-
-<p>There is a <a href='https://www.patreon.com/posts/premultiplied-in-21014115'>post on patreon</a> with 
further details about the implementation.</p>
-
   <a name='TODO'></a>
 <!--TODO-->          
 
diff --git a/tests/transparent_symmetry.c b/tests/transparent_symmetry.c
index 90a0974..a42709a 100644
--- a/tests/transparent_symmetry.c
+++ b/tests/transparent_symmetry.c
@@ -20,20 +20,22 @@
 #include <math.h>
 #include "babl-internal.h"
 
-#define TOLERANCE    0.000001
-#define PIXELS       10
+#define TOLERANCE    0.001
+#define PIXELS       12
 
 float source_buf [PIXELS * 4] =
-{ 10.0, 1.0, 0.1, 1.0,
-  10.0, 1.0, 0.1, 0.5,
-  10.0, 1.0, 0.1, 0.1,
-  10.0, 1.0, 0.1, 0.01,
-  10.0, 1.0, 0.1, -0.01,
-  10.0, 1.0, 0.1, 1.5,
-  10.0, 1.0, 0.0001, 0.000001,
-  10.0, 1.0, 0.1, -0.00001,
-  10.0, 1.0, 0.1, 0.0,
-  10.0, 1.0, 0.1, -0.5,
+{ 10.0, 1.0, 0.1,      1.0,
+  10.0, 1.0, 0.1,      0.5,
+  10.0, 1.0, 0.1,      0.1,
+  10.0, 1.0, 0.1,      0.01,
+  10.0, 1.0, 0.1,     -0.01,
+  10.0, 1.0, 0.1,      1.5,
+  10.0, 1.0, 0.0001,   0.000001,
+  10.0, 1.0, 0.1 ,    -0.00001,
+  10.0, 1.0, 0.1,      0.0,
+  10.0, 1.0, 0.1,     -0.5,
+  1000.0,10000.0, 100000.0, 0.001,
+  5000.0,50000.0, 500000.0, 0.01,
 };
 
 float bounce_buf [PIXELS * 4];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]