From: Øyvind Kolås Date: Sun, 18 Aug 2019 13:28:52 +0000 (+0200) Subject: docs: update alpha docs X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5bcddad4eb90ce0070db1714ccacb6d4c72e631b;p=babl.git docs: update alpha docs --- diff --git a/docs/Glossary-static.html b/docs/Glossary-static.html index 7d7364d..7f91b77 100644 --- a/docs/Glossary-static.html +++ b/docs/Glossary-static.html @@ -39,7 +39,7 @@ keep the vocabulary small.

own associated alpha. This representation is useful for avoiding color from empty pixels bleeding into surroundings. It is also able to represent emittance in addition to opacity. -Babl uses Symmetric alpha transformations between separate alpha and associated alpha. +Babl uses Unified alpha transformations between separate alpha and associated alpha.
BablFish
@@ -72,16 +72,13 @@ relevant spaces - the ICC profile for the space.
Luminance
The photometric measure of luminious intensity of per unit area of light. The luminance in babl is proportional to luminance - though it doesn't use the SI unit of candela per square meter.
-
Non-associated alpha
-
deprecated term, see separate alpha
-
Premultiplied alpha
deprecated term, see associated alpha
-
Separate alpha
-
This representation of pixels has alpha as a fully separate component, +
Straight alpha
+
Straight or separate alpha has alpha as a fully separate component, that can be adjusted without affecting the color. -Babl uses Symmetric alpha transformations between separate and associated alpha.
+Babl uses symetric alpha transformations between straight and associated alpha.
TRC
diff --git a/docs/SymmetricAlpha-static.html b/docs/SymmetricAlpha-static.html deleted file mode 100644 index 959f0db..0000000 --- a/docs/SymmetricAlpha-static.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - Symmetric Alpha - babl - - - - - - - -
- -
- - -
-
- -

Symmetric transformations for floating point alpha

- - -

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 -replaces asymptotic behavior and direct precision loss of color precision when -multiplying or dividing by alphas near 0.0 with a consistent symmetric -transformation.

- -

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.

- -
-    #define BABL_ALPHA_FLOOR    (1.0/65536.0)
-    #define BABL_ALPHA_FLOOR_F  (1.0f/65536.0f)
-
- -

The deviation from not clamping near 0.0 is within the quantization margin -of 16bit integer alpha, thus no adaptations for any SIMD or and similar 8bit -and 16bit extensions of pixel format conversions are needed. -

- -

This is the clamping function in use:

-
-static inline float
-babl_epsilon_for_zero_float (float value)
-{
- if (value <= BABL_ALPHA_FLOOR_F &&
-     value >= -BABL_ALPHA_FLOOR_F)
-   return BABL_ALPHA_FLOOR_F;
- else
-   return value;
-}
-
-

And an example use of this clamping function that is consistent with babls behavior:

-
-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;
-}
-
- - -

For more detils see the commit message of the most recent refinement as well as blog post with further background.

- - - - /babl -
-
- -
-
-  -
-
- - - diff --git a/docs/UnifiedAlpha-static.html b/docs/UnifiedAlpha-static.html new file mode 100644 index 0000000..9b94806 --- /dev/null +++ b/docs/UnifiedAlpha-static.html @@ -0,0 +1,110 @@ + + + + + + + + Unified Alpha - babl + + + + + + + +
+ +
+ + +
+
+ +

Symmetric transformations for floating point alpha

+ + +

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 +replaces asymptotic behavior and direct precision loss of color precision when +multiplying or dividing by alphas near 0.0 with a consistent symmetric +transformation.

+ +

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.

+ +
+    #define BABL_ALPHA_FLOOR    (1.0/65536.0)
+    #define BABL_ALPHA_FLOOR_F  (1.0f/65536.0f)
+
+ +

The deviation from not clamping near 0.0 is within the quantization margin +of 16bit integer alpha, thus no adaptations for any SIMD or and similar 8bit +and 16bit extensions of pixel format conversions are needed. +

+ +

This is the clamping function in use:

+
+static inline float
+babl_epsilon_for_zero_float (float value)
+{
+ if (value <= BABL_ALPHA_FLOOR_F &&
+     value >= -BABL_ALPHA_FLOOR_F)
+   return BABL_ALPHA_FLOOR_F;
+ else
+   return value;
+}
+
+

And an example use of this clamping function that is consistent with babls behavior:

+
+static inline void
+associated_to_separate_rgba (const float *associated_rgba,
+                                   float *separate_rgba)
+{
+  float alpha = associated_rgba[3];
+  float reciprocal_alpha = 1.0f / babl_epsilon_for_zero_float (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;
+}
+
+
+static inline void
+separate_to_associated_rgba (const float *separate_rgba,
+                                   float *associated_rgba)
+{
+  float alpha = associated_rgba[3];
+  float limited_alpha = babl_epsilon_for_zero_float (alpha);
+
+  associated_rgba[0] = separate_rgba[0] * limited_alpha;
+  associated_rgba[1] = separate_rgba[1] * limited_alpha;
+  associated_rgba[2] = separate_rgba[2] * limited_alpha;
+  associated_rgba[3] = alpha;
+}
+
+ + +

For more detils see the commit message of the most recent refinement as well as blog post with further background.

+ + + + /babl +
+
+ +
+
+  +
+
+ + + diff --git a/docs/index-static.html.in b/docs/index-static.html.in index df131f1..92a9c9b 100644 --- a/docs/index-static.html.in +++ b/docs/index-static.html.in @@ -55,7 +55,7 @@
  • Runtime profiling/validating and code-path optimizing with persistence of profiling data across runs, with caching of results.
  • Can load Color Spaces from ICC v2 and v4 profiles containing RGB matrix + TRC and with lcms2 dependency also CMYK profiles.
  • -
  • Uses Symmetric Alpha conversions for conversions between separate and associate alpha, avoiding loss of color fidelity due to asymptotic behavior near alpha 0.0 in floating point.
  • +
  • Uses Unified Alpha conversions for conversions between separate and associate alpha, avoiding loss of color fidelity due to asymptotic behavior when dividing by 0.0 in floating point.
  • Portable self contained C code working on win32, linux, bsds and mac on 32bit and 64bit systems.
  • Stable, small API, with singleton objects returned.
  • diff --git a/docs/meson.build b/docs/meson.build index d085b80..01b6c30 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -130,12 +130,12 @@ ColorManagement_html = custom_target('ColorManagement.html', build_by_default: true, ) -SymmetricAlpha_html = custom_target('SymmetricAlpha.html', +UnifiedAlpha_html = custom_target('UnifiedAlpha.html', input : [ - 'SymmetricAlpha-static.html', + 'UnifiedAlpha-static.html', 'toc', ], - output: [ 'SymmetricAlpha.html', ], + output: [ 'UnifiedAlpha.html', ], command: [ env_bin, 'cp', '@INPUT0@', '@OUTPUT@', @@ -144,7 +144,6 @@ SymmetricAlpha_html = custom_target('SymmetricAlpha.html', build_by_default: true, ) - run_target('push_web', command: [ 'scp', index_html, index_static_html, babl_css, scptarget, diff --git a/docs/toc b/docs/toc index ec3685a..ffbf61d 100644 --- a/docs/toc +++ b/docs/toc @@ -8,7 +8,7 @@
  •   Reference
  •   Glossary
  •   Color Management
  • -
  •   Symmetric-Alpha
  • +
  •   Unified-Alpha
  •   CMYK
  •   Usage