PDA

View Full Version : how to calculate saturation? U,V not scaled equally


jmac698
8th March 2006, 06:14
Maybe u, v are scaled differently.
I calculated sat=sqr(u*u+v*v), where u,v were scaled to (-1,1).
Then /sqr(2)*100 to get percent. I entered a table of 100% colorbars. I get:

100% colorbars
color Y Cb Cr Saturation
white 235 128 128 0
yellow 210 16 146 72
cyan 170 166 16 75
green 145 54 34 76
magenta 106 202 222 76
red 81 90 240 75
blue 41 240 110 72
black 16 128 128 0

They should all be the same, at least. I tried color tools vdf, it seems to have the same problem, colorbars don't fit into the boxes and are different radiuses. So I think no one else has figured out the problem, that means I must :)

jmac698
8th March 2006, 17:25
If I rotate 9.09deg, with v*.94, it's much better. It was scaled originally to fit into a composite signal, that had limits. I'll have to rederive everything :( hanfrunz may be interested for the vectorscope filter.
Anyone good at math?

hanfrunz
8th March 2006, 22:42
If I rotate 9.09deg, with v*.94, it's much better. It was scaled originally to fit into a composite signal, that had limits. I'll have to rederive everything :( hanfrunz may be interested for the vectorscope filter.
Anyone good at math?

The analogue Pr and Pb signals are scaled like this:
Pb = 0,564 * (B'-Y')
Pr = 0,713* (R'-Y')

you can't just use your sqrt()-formula to calculate the saturation. You should check out the formulas in ITU-R601 to get the scale factors for the digital Cr and Cb. I am to tired for this right now :)

my vectorscope-filter will just paint the markers to the "official" values. (i will release a fresh version with a GUI soon)

hanfrunz

jmac698
8th March 2006, 23:33
Pb=0,5/(1-0,114)(B-Y)=0,5/(0,564)..
Pr=0,5/(1-0,299)(R-Y)=0,5/(0,713)..

Cb=128+112*Pb
Cr=128+112*Pr

U=0,492111(B-Y)
V=0,877283(R-Y)

I tried several combinations, but none gave me the consistent saturation values I was looking for. The search goes on...

Is there a standard for vectorscopes? In my opinion, have this strange scaling makes it harder to estimate how close a color is to being correct, I would rather have a display which is scaled correctly to Hue/Saturation.

Note: all letters should have ticks (Y') to denote this is after gamma correction. But I don't bother :)

hanfrunz
9th March 2006, 11:53
i think the main problem is the definition of saturation. I learned saturation is the ammount of grey in a color. If there is no grey in the color it is 100% saturated.

Example1: R=100, G=100, B=0 is 100% saturated, because there is no grey in it

Example2: R=100, G=100, B=100 is 0% saturated, because it's grey

Example3: R=255, G=255, B=128 is 50% saturated because it's
R128+ G128+B128 = 50% grey + R127+G127

Example4: R=10, G=128, B=60
ammount of grey is R10+G10+B10 -> so we have (255-10)/255=0,96 -> 96% Saturation (Photoshop tells me it's 92%!?)

In YUV colorspaces saturation means the lenghts of the uv vector, which is something different. So i think a vectorscope should not be mistaken for a saturation-meter.

IanB
10th March 2006, 02:20
@jmac698,

In YUV space saturation is the ratio of the [u,v] vector versus the maximum length of a [u,v] vector of the same hue. The locus is a lop sided ellipse.

The maximum length for a given hue is when at least one of R, G or B would try to greater than 1 or less than 0 when converted back to RGB colour space.

In your initial table all values are 100% saturation (within rounding error) because each vector is at its maximum length for uncliped conversion back to RGB colour space.

@hanfrunz,

Photoshop use the max(r, g, b) as the argument thus (128-10)/128=0.92

Think about R=0, G=128, B=60 it is 100% saturated.

jmac698
10th March 2006, 04:11
@ianb
Thanks, that gave me a simple idea, there must be a graphics gem for finding an elipse from 3 points, so I can map it back to a circle.