"Bill Buckels" <
bbuc...@mts.net> wrote:
>computational errors that occur in HLS between the Cyan and Blue scales...
Correction: That should have said GREEN and CYAN scales.
Some further detail is in order here for folks who actually know about the
HLS color model...
http://en.wikipedia.org/wiki/HLS_color_space
HLS has less to do with color perception than providing a measurement of
color. It is like mixing a paint formula or printing in the Analog World,
except that in the Analog World, building color is subtractive, starting
with a light or white base and adding tints or ink to make them darker, and
in the Digital World we start with a black screen and add to RGB gun values
to make colors lighter. On a computer screen we can only control colors by
scale the same way we do with paint tones (HUE degrees) and paint shades
(HUE distance aka SATURATION and lightness aka LUMINANCE). But by
definition, a digital scale is fixed to a sample or bit depth and an analog
scale is neither fixed nor linear. Consistent and measured paint shades like
computer colors are fixed when mixed. And what how paint or print responds
to photons depends on what kind of finish has been applied Computer colors
do not absorb photons like unfinished paint nor are they reflective like
gloss finish; Computer screens emit photons like the sun. Whether one paints
a wall, or renders color in an image on an Apple IIgs in SHR mode or on a
Modern computer screen in 2-bit or greater color, achieving white balance
provides a base value, but representing what a color looks like when a cloud
passes overhead on a sunny day, or in the sunset facing east, or on a
moonlit night is beyond the scope of HLS to model without some additional
help.
As a paint mixing formula or a computer color formula, HLS works well enough
for general purpose use.
In image converters and editors like PhotoShop or my SuperSat utility for
preprocessing BMP files destined for conversion to Apple IIgs SHR files with
BMP2SHR, colors in an image can be separated into smaller groups called
channels to perform adjustments and transformations exclusive to the colors
in a particular channel. I don't know or care how PhotoShop calculates its
RGB channels:
http://www.photoshopessentials.com/essentials/rgb/
SuperSat now provides 2 types of channels; RGB and HUE.
HUE uses a polar coordinate system and is conveniently expressed in degrees
but is really a linear measurement. LUMINANCE and SATURATION provide the
other metrics for calculating a color point using the 6 HUE channels which
are really 6 hexaconic sections.
http://en.wikipedia.org/wiki/Hue
HUE and TONE mean the same thing. In paint color, a primary color wheel can
express hue (tone) in12 channels in which case a 12 sided polycone with hue
channels of 3 primary colors of RGB, 3 secondary colors of YCM, and six
intermediate tertiary colors; 12 channels would express hue in 30 degree
segments rather than the 60 degree segments in the 6 HLS channels, or the
120 degree segments in the RGB channels. The measurement is the same idea,
the channels are smaller:
http://www.color-wheel-artist.com/hue.html
My Hue Channel Frequency Calculations and Color Channel Frequency
Calculations for a 24 bit color are based on Frank Preucil's "Color Circle"
Polar Plot:
Please send me private mail if you want the C code for calculating 6 - HUE
channels and 3 - RGB channels. I may also have a calculater for 12 sided
polyconic 12 - TONE channels written by then.
Throughout my testimg the calculation itself showed no error. However a
computational error occurs if an implementation uses a single precision
floating point storage class in the kernel instead of a double precision
storage class, as follows:
x---x
IEEE 754 single-precision binary floating-point format: binary32
Red Hue Bucket = 2796160 possible colors
Yellow Hue Bucket = 2796160 possible colors
Green Hue Bucket = 2796584 possible colors
Cyan Hue Bucket = 2795736 possible colors
Blue Hue Bucket = 2796160 possible colors
Magenta Hue Bucket = 2796160 possible colors
Red Color Bucket = 5592320 possible colors
Green Color Bucket = 5592320 possible colors
Blue Color Bucket = 5592320 possible colors
GreyScale Count (Black, White, and Shades of Grey) = 256
The error between the colors grouped to the GREEN and CYAN is caused by
pecision loss in values coming close to the limits of the single precision
storage class.
x---x
IEEE 754 double-precision binary floating-point format: binary64
Red Hue Bucket = 2796160 possible colors
Yellow Hue Bucket = 2796160 possible colors
Green Hue Bucket = 2796160 possible colors
Cyan Hue Bucket = 2796160 possible colors
Blue Hue Bucket = 2796160 possible colors
Magenta Hue Bucket = 2796160 possible colors
Red Color Bucket = 5592320 possible colors
Green Color Bucket = 5592320 possible colors
Blue Color Bucket = 5592320 possible colors
GreyScale Count (Black, White, and Shades of Grey) = 256
x---x
>which I discovered doing the implementation of hue in SuperSat's Hue
>Channel algorithms...
Correction (sort of): I probably did not discover this computational error
on behalf of the entire planet; only for myself. I also did not discover the
limit of single precion floating point storage class. Like Latin the limit
is fixed.
I discovered the limit of double precision when I was an adult student doing
a strength of materials formulae assignment. My instructor used a pocket
calculator to develop the answers. I did the assignmnet on paper and made
each calculation longhand and in analog.
For every "wrong" answer I proved his calculator "wrong" and got 100% on the
assignment. However he still gave the other students whose wrong answers
matched his wrong answers 100%.
The HLS color model is like that too. So if you use the Polar Plot don't use
floats, use doubles, or you could end-up with the computationally right
wrong answers when the HUE degree calculation in the GREEN CYAN area
reaches the storage class limit and loses precision (or signs itself).
As an interesting aside on HUE degrees, the Window Color Picker uses a Hue
Scale of 0-239 which actually represents increments of 1.5 degrees. Therefor
it is not possible to adjust hue using this to the same accuracy as in a
program that uses 1 degree increments. Whether this matters is much like the
rest of this HLS business.
With a limit of 4096 possible colors on the SHR display, and its other
constraints, and an input of 16.7 million possible colors, results will
vary.
Bill