|
|
#1 |
|
Junior Member
Join Date: Jul 2002
Posts: 32
|
HSV to RGB
Hey guys, I'm working on some presets which I would like to use the HSV colorspace instead of RGB. However, AVS doesn't support HSV in the superscope code. I have searched on Google for an AVS-friendly algorithm, but I haven't been able to find one.
Does anyone know of a (relatively) easy way to convert between colorspaces? Thanks |
|
|
|
|
|
#2 |
|
Major Dude
|
i use this, it's a method that unconed posted here in the forums:
hue=var; // (0..2PI) sat=var; // (0..1) lum=var; // use any value to light/darken the color, recomended value (-1..1) red=(sin(hue)+1)*sat*0.5+lum; green=(sin(hue+2.09)+1)*sat*0.5+lum; blue=(sin(hue+4.18)+1)*sat*0.5+lum; batman |
|
|
|
|
|
#3 |
|
Forum King
|
Assuming red, green, blue, hue, luminosity, and saturation are all values from 0 to 1:
red=|sin hue*pi*2)|*saturation/2+luminosity; green=|sin hue*pi*2+pi/3)|*saturation/2+luminosity; blue=|sin hue*pi*2+pi/3*2)|*saturation/2+luminosity; Fast version for AVS: init: tpi=acos(-1)*2; pit=tpi/6; tpit=pit*2; pixel: sat2=sat/2; red=abs(sin(hue*tpi))*sat2+lum; green=abs(sin(hue*tpi+pit))*sat2+lum; blue=abs(sin(hue*tpi+tpit))*sat2+lum; "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
|
|
|
|
|
#5 |
|
Forum King
|
Oh, and hue2=hue*tpi;
"guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings |
|
|
|
|
|
#6 |
|
Major Dude
Join Date: Apr 2002
Location: Ballarat, Australia
Posts: 529
|
Here's what I use (I don't think it's accurate, but it does the job).
Init code: Point code: h = hue, s = saturation, br = brightness. Note: This can be optimized further by creating varibles for things like (h-tt)*pi. Also can be optimized if hue or saturation is fixed. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|