Hi All,
Download this GUI Stack for Scott Raney's Color Conversion Functions:
RGB to HSV and HSV to RGB.
Only for certain colors this is a lossy conversion: Once you convert some
RGB colors to HSV, the function HSVtoRGB does not restore them back
exactly as before.
Does anyone knows (or have created) a pair of RGBtoHSV and HSVtoRGB
color conversion functions that do not lose or change color information?
Thanks in advance!
Al
Color Conversion - RGB to HSV and back... (almost)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Color Conversion - RGB to HSV and back... (almost)
Alejandro,
the problem is here the integer rounding.
An integer RGB triple converts correctly to HSV/HSL expressed as floats.
You can then go back 'exactly' (if the floats are exact enough) to RGB.
But obviously you can't go back from the HSV/HSL floats _changed to integer_ to the same RGB. The error will usually be within plus/minus 1 of 255.
H.
the problem is here the integer rounding.
An integer RGB triple converts correctly to HSV/HSL expressed as floats.
You can then go back 'exactly' (if the floats are exact enough) to RGB.
But obviously you can't go back from the HSV/HSL floats _changed to integer_ to the same RGB. The error will usually be within plus/minus 1 of 255.
H.
shiftLock happens
Re: Color Conversion - RGB to HSV and back... (almost)
I understand. Then, I just need to change a single number in this script:
Change the script of button "HSV to RGB" from this:
if the number of lines of fld 2 = 2 then
put line 2 of fld 2 into w
To this:
if the number of lines of fld 2 = 2 then
put line 1 of fld 2 into w
Many thanks for pointing this!
Al
Change the script of button "HSV to RGB" from this:
if the number of lines of fld 2 = 2 then
put line 2 of fld 2 into w
To this:
if the number of lines of fld 2 = 2 then
put line 1 of fld 2 into w
Many thanks for pointing this!
Al