Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Hsvadjust
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
Wilbert
Posted: Feb 3 2011, 08:24 PM


Advanced Member


Group: Members
Posts: 132
Member No.: 6270
Joined: 11-September 03



Hi Avery!

I made a HSVAdjust plugin for AviSynth (i need to include HSL/HSI yet, but that's not important here) and i compared it to the build-in filter in Virtualdub (1.9.11).

When using a blankclip of R=235,G=0,B=0 with "hue=35,saturation=75%" i got the following values (formulas from wikipedia):

M = 235, m=0 => C=235
H = 60*( G - B )/C = 60*(0-0)/235 = 0
S = C/M = 235/235 = 1
V = M = 235

S' = 0.75*S = 0.75
H' = 0 + 35 = 35
V' = 0+1*235 = 235

Hi = int(H'/60) = 0
f = H'/60 - Hi = 0.5833

R = V' = 235
G = V'*(1-(1-f)*S') = 161.5566 = 162
B = V'*(1-S') = 58.75 = 59

The output of Virtualdub seems to be very different: R=206, G=132, B=29. Any idea why it's that way off?
 
     Top
phaeron
Posted: Feb 5 2011, 07:21 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



The saturation calculations are different, because VirtualDub's filter converges to the midrange as saturation goes to zero instead of the top. According to Wikipedia, this is actually an HSL model instead of HSV, although there's probably some differing opinions on this. I don't remember where I got the original model from -- might have been Graphics Gems I.
 
    Top
Wilbert
Posted: Feb 12 2011, 09:35 PM


Advanced Member


Group: Members
Posts: 132
Member No.: 6270
Joined: 11-September 03



Thanks for your clarification! For the ones who are interested:


M = 235, m=0 => C=235
H = 60*( G - B )/C = 60*(0-0)/235 = 0
L = (M+m)/2 = 117,50
S = C/(255-|2L-255|) = 235/235 = 1

S' = 0.75*S = 0.75
H' = 0 + 35 = 35
L' = 0+1*117,50 = 117,50
C' = (255-|255-2L'|)*S' = 176,25
m' = L' - C'/2 = 29,375

Hi = int(H'/60) = 0
f = H'/60 - Hi = 0.5833

R = C' + m' = 205,625 = 206
G = f*C' + m' = 132,1875 = 132
B = m' = 29,375 = 29
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
2 replies since Feb 3 2011, 08:24 PM Track this topic | Email this topic | Print this topic

<< Back to Testing / Bug Reports