RGB- and HLS-Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks >

RGB- and HLS-Operations

 

What is HLS ?

 

The hexadecimal colours and the RGB colours use amounts of Red Green and Blue to describe colours.
This is a nice analogue to how the pixels in the screen are lighting up.

On the other side it makes picking a colour not very human friendly.

 

A human way to think of colour asks questions like:

Is it light or dark?

What colour is it?

Is it vibrantly coloured?

 

E.g. Dark Vibrant Red or Light Pale Pink

 

There is a way of defining colours based on these propertiess.

This is the hLS - System. It helps you, adjust a colour lighter or darker or more colourful.

Or more red or more blue.

 

To convert your colors into our HLS-Format you can also use:

Color Converter

The values at "WinHSL 240" are our values from the SPR.

 

You can find a nice HLS-Colorpicker here:

https://hslpicker.com/

or here

http://www.workwithcolor.com/hsl-color-picker-01.htm

but you will need to convert the values to WinHLS240 using the Converter here.

 

What are the numbers from HLS ?

HLS is another Description for Color-Information.

It contains the 3 Components: H,L and S.

 

0-239 Hue is wavelength color.

0-240 Luminosity (brightness, brilliance) is black 0(0%) to white240(100%).

0-240 Saturation is relative bandwidth amount of grey in a color. 0(0%) to 240(100%)  

 

as you can see, the Range from HLS is not exactly the same like it was RGB.

 

Due to the limited Resolution of WinHLS (Goes up to 239/240 while RGB goes up to 255)

a conversion "back and forth" will look like in the picture below and has some "stairs".

 

' Depending on your Computer this Script may run for several seconds.

'

CAL.$$XSZ=10200/8

CAL.$$YSZ=6800/8

ANA.New|0|$$XSZ|$$YSZ

ANA.vgradient|0|&HFF00FF|&H000000

ANA.New|1|$$XSZ|$$YSZ

ANA.hgradient|1|&H0000FF|&H00FFFF

ANA.Mix|0|1|7

ANA.Show|1!

ANA.RGB_HLS_IR|1|2

ANA.Show|2!

ANA.HLS_RGB_IR|2|3

DMP.1

ANA.Show|3!

ENR.

 

 

Converted

 

RGB -> HLS

 

 

' Test RGB->HLS Conversion

' The Output is in the SPRE-Debug-Window

'

DBP.==============================

GUT.Input R,G,B||113,100,227|$$ERG

SBD.$$ERG|,|1|$$RED

SBD.$$ERG|,|2|$$GRN

SBD.$$ERG|,|3|$$BLU

DBP.RGB=$$RED,$$GRN,$$BLU

VTH.$$RED|$$RED|2

VTH.$$GRN|$$GRN|2

VTH.$$BLU|$$BLU|2

$$RGB=&H$$RED$$GRN$$BLU

DBP.RGB=$$RGB

ANA.RGB_To_HLS|$$RGB|$$HLS

VTH.$$HLS||6

DBP.HLS=$$HLS

GSS.1|2|$$HLS|$$HUE

GSS.3|4|$$HLS|$$LUM

GSS.5|6|$$HLS|$$SAT

VBT.$$HUE

' We use VAN. to make Decimal out of Hex-Values

VAN.$$HUA=&H$$HUE

VAN.$$LUA=&H$$LUM

VAN.$$SAA=&H$$SAT

VAR.$$OUT=H=$$HUA # L=$$LUA  #  S=$$SAA

DBP.HLS=$$OUT

ENR.

 

 

' HLS -> RGB Converter

' The Output is in the SPRE-Debug-Window

'

DBP.==============================

GUT.Input H,L,S||113,100,227|$$ERG

SBD.$$ERG|,|1|$$HUE

SBD.$$ERG|,|2|$$LUM

SBD.$$ERG|,|3|$$SAT

DBP.HLS=$$HUE,$$LUM,$$SAT

VTH.$$HUE|$$HUE|2

VTH.$$LUM|$$LUM|2

VTH.$$SAT|$$SAT|2

$$HLS=&H$$HUE$$LUM$$SAT

DBP.HLS=$$HLS

ANA.HLS_To_RGB|$$HLS|$$RGB

VTH.$$RGB||6

DBP.RGB=$$RGB

GSS.1|2|$$RGB|$$RED

GSS.3|4|$$RGB|$$GRN

GSS.5|6|$$RGB|$$BLU

VBT.$$RED

VAN.$$REA=&H$$RED

VAN.$$GRA=&H$$GRN

VAN.$$BLA=&H$$BLU

VAR.$$OUT=R=$$REA # G=$$GRA  #  B=$$BLA

DBP.RGB=$$OUT

ENR.