Skip to main content.
December 13th, 2005

Back to work, back on the scale and HSV color-space

Today I went back to work ! There is already something to fix, but luckily, not a terrible pressure.
I also went to the gym after having missed it a few times recently, as I was enjoying my vacation. I now weight 70.75, which is 5 grams more than where I’m supposed to be in 3 days …but I didn’t go to the bathroom for the day !
Not having had to go to work helped to lose weight. I was so busy with other things, and because I had no schedule, I wasn’t compelled to have a damn whole lunch every day while having plenty of time to sleep. Indeed (for what is worth it) I recently read from ansa.it that some research says that lack of sleep and weight gain go together.

The other day I tried to improve the compression for dsharingu. As usual, sub-sampling the chromatic components spatially (one pixel every 4). However that turned out like a complete mess. ClearType & co. is a problem, as expected. It’s like noise that needs to be filtered out, or will turn nasty when compressing. Also my naive YC format didn’t really scale well with spatial sub-sampling.
I eventually turned to HSV (Hue Saturation Value), which is another name for HSI (Hue Saturation Intensity), but which was originally called HWB (Hue Whiteness Brightness).
I actually wasted a lot of time trying to find out more about HWB, before realizing that was nothing but HSV !
One problem with this HSV (or whatever one calls it), is that it’s not explained in a very intuitive way. Or perhaps I’m just dumb ! Anyway, I eventually figured out the magic about it:
For RGB->HSV, find the maximum and minimum of the given R, G and B, values. Use the maximum value for V. Saturation and a third value (that I call T here) are coefficients to use to find the other two values. If, for example V is for R, then S and T are used to find G and B.

When going from TSV->RGB, if R was the max, it could be:
R = V
G = V * (1 - S * T)
B = V * (1 - S * (1 - T))

This is what I called TSV and it’s not very useful because it still needs some information to specify which value was the max and which was the min ! If for example, G was the max, then:

G = V
B = V * (1 - S * T)
R = V * (1 - S * (1 - T))

This information needs to be stored. Let’s say in a variable called P (as permutation or palette). Every value of P corresponds to a combination: RGB, GBR, BGR, … there are 6 of them. All possible combinations of 3 values are 3! (3 * 2 * 1).
Now we have a new, complete, color format called PTSV. This is pretty much HSV. In fact, P and T can also be unified in one variable:

(H,S,V) = ((P+T),S,V)

This works because T = [0,1) (or, from 0 to 0.999999~) and P = { 0, 1, 2, 3, 4, 5 }

Thus, the integer part of H tells me the permutation and the fractional part is T.

P = trunc( H )
T = H - trunc( H )

if H = 4.51, then
P = 4
T = 4.51 - 4 = 0.51

..it’s a bit messy. I prefer to think in terms of PTSV.

I must say that, to be accurate, the actual H should be an angle, therefore T should be interpolated angularly and not linearly !
However, speed is one of my major goals. Also, if one really wants to get fancy, it would probably be more elegant to throw in the complex plane to describe the color format. Not sure if it has been done, but I’m clearly no the one that will try do that.. at least for the time being !

zzzzzzzzzz !!!!!!!

Edit: Sad !!! I shouldn’t have rushed to explain something I don’t really know..
I meant to come up just with the P and T separation thing, but I went to explain a little too much, into the realm of bullshit.
Actually, with the previous explanation, it was easier to understand the concept of storing a main component and two coefficients, but that was a bit too fictional when compared to the actual HSV.
Should be better now !

Posted by Davide Pasca in Image-processing, Diary

This entry was posted on Tuesday, December 13th, 2005 at 2:31 am and is filed under Image-processing, Diary. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “Back to work, back on the scale and HSV color-space”

  1. rasty says:

    PD!! (and PM too!)

  2. Davide Pasca says:

    Mr.Rasty: since you had to say it.. perhaps now you want to explain, in English, what’s the joke about ;)
    PD and PM have been used as well temporarely as I was trying to understand things ;)
    ..Incidentally, they are also the initials of my name and my sister’s !

  3. rince says:

    Hohohoh I know what PD and PM stands for! No English explanation required for me. I also know VC and MT!!!!

  4. rasty says:

    Woo I didn’t realize PM were your sister’s initials too! Maybe a subtle joke from your parents?

  5. Davide Pasca says:

    rince, I can guess VC, but MT.. well I can guess that one too, but not sure if my guess is right. Would that expression, by any chance, involve the the Virgin Mary ? 8)

    rasty.. or maybe just a genuine reaction ?!

  6. Michael says:

    Ha… Thank you for noting this. I have spent a lot of time trying to track down the elusive HWB… now I realize why I could not find it.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>