<< Click to Display Table of Contents >> Navigation: 3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > RGB- and HLS-Operations > Image/Pixel-Color Operations |
MiniRobotLanguage (MRL)
ANA.HLS_To_RGB
ANA.RGB_To_HLS
Convert values (Single or splitted vaues) from R,G B to H,L,S and opposite direction
Intention
This command will convert single values like &HF1F0A0 or Splitted values where R/G/B or H/L/S are splitted in 3 Parameters from R,G, B into H,L,S and the opposite direction.
To convert a Full-IR between HLS and RGB use other commands.
To convert your colors into our "WinHSL240"-Format, - here in short - HLS-Format, you can also use:
The values at "WinHSL 240" are our values from the SPR.
Due to technical rounding, our values may differ +/-3 with the values on the WEB-Site.
These commands can be called with a variety of Parameters.
' R=113 G=100 B=229 (&H7164E5)
' H=164 L=155 S=171 (&HA49BAB)
'***********************************
' 1-1 Conversion
'***********************************
$$RGB=&H7164E5
ANA.RGB_To_HLS|$$RGB|$$HLS
VTH.$$HLS||6
DBP.$$HLS
' Result is &HA49BAB
ENR.
$$HLS=&HA49BAB
ANA.HLS_To_RGB|$$HLS|$$RGB
VTH.$$RGB||6
DBP.$$RGB
' Result is &H7164E6
ENR.
'***********************************
' 1-3 Conversion
'***********************************
$$RGB=&H7164E5
ANA.RGB_To_HLS|$$RGB|$$HUE|$$LUM|$$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
' Result is &HA49BAB
ENR.
$$HLS=&HA49BAB
ANA.HLS_To_RGB|$$HLS|$$RED|$$GRN|$$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
' Result is &H7164E6
ENR.
'***********************************
' 3-1 Conversion
' Using the 3-1 Syntax, the result is always on TOS,
' You always use 3 Parameters
' to not intermix it with the 13-Conversions that uses 4 Parameters
'***********************************
$$HUE=&HA4
$$LUM=&H9B
$$SAT=&HAB
ANA.HLS_To_RGB|$$HUE|$$LUM|$$SAT
POP.$$RES
VTH.$$RES||6
DBP.RGB=$$RES
' Result is &H7164E6
ENR.
$$RED=&H71
$$GRN=&H64
$$BLU=&HE5
ANA.RGB_To_HLS|$$RED|$$GRN|$$BLU
POP.$$RES
VTH.$$RES||6
DBP.HLS=$$RES
' Result is &HA49BAB
ENR.
'***********************************
' 3-3 Conversion
'***********************************
$$RED=&H71
$$GRN=&H64
$$BLU=&HE5
ANA.RGB_To_HLS|$$RED|$$GRN|$$BLU|$$HUE|$$LUM|$$SAT
DBP.HLS=$$HUE-$$LUM-$$SAT
' Result is HLS=164-155-171
ENR.
$$HUE=&HA4
$$LUM=&H9B
$$SAT=&HAB
ANA.HLS_To_RGB|$$HUE|$$LUM|$$SAT|$$RED|$$GRN|$$BLU
DBP.RGB=$$RED-$$GRN-$$BLU
' Result is RGB=113-100-230
ENR.
Here are 2 Programs where you can enter an RGB / HSL Value and then get the result of the conversion.
' 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.
Syntax
These Functions can be called with a different number of Paramenters. Depending on these number the Parameter have different meaning.
ANA.HLS_To_RGB|P1
ANA.RGB_To_HLS|P1
Parameter Explanation
P1 - Source Value for RGB / HLS. Example: &HF1A9B4 This value is interpreted as RGB or as HLS value.
The result of the Operation will be placed on TOS.
ANA.HLS_To_RGB|P1|P2
ANA.RGB_To_HLS|P1|P2
Parameter Explanation
P1 - Source Value for RGB / HLS. Example: &HF1A9B4 This value is interpreted as RGB or as HLS value.
P2 - Variable for Result.
ANA.HLS_To_RGB|P1|P2]|P3
ANA.RGB_To_HLS|P1|P2]|P3
Parameter Explanation
P1 - Source Value/Variable for Red / Hue.
P2 - Source Value/Variable for Green / Luminosity.
P3 - Source Value/Variable for Blue / Saturation.
The result of the Operation will be placed on TOS.
ANA.HLS_To_RGB|P1|P2|P3|P4
ANA.RGB_To_HLS|P1|P2|P3|P4
Parameter Explanation
P1 - Source Value for RGB / HLS. Example: &HF1A9B4 This value is interpreted as RGB or as HLS value.
P2 - Destination Variable for Red / Hue.
P3 - Destination Variable Green / Luminosity.
P4 - Destination Variable Blue / Saturation.
ANA.HLS_To_RGB|P1|P2|P3|P4|P5|P6
ANA.RGB_To_HLS|P1|P2|P3|P4|P5|P6
Parameter Explanation
P1 - Source Value/Variable for Red / Hue.
P2 - Source Value/Variable for Green / Luminosity.
P3 - Source Value/Variable for Blue / Saturation.
P4 - Destination Variable for Red / Hue.
P5 - Destination Variable Green / Luminosity.
P6 - Destination Variable Blue / Saturation.
Example
-
Remarks
-
Limitations:
-
See also: