Shop OBEX P1 Docs P2 Docs Learn Events
ColorPAL output interpretation — Parallax Forums

ColorPAL output interpretation

ismailkismailk Posts: 2
edited 2012-04-23 06:33 in Accessories
Hi,

After a long and painful learning process I've succesfully interfaced my ColorPAL #28380 with PIC18F4550.
Even though I've read literally all the blogs and posts about output interpretation and white balancing, I'm still confused.

Here is my code to get the output values and convert them to 0-255 range.
hexCharToInt(x[0]) * 256 + hexCharToInt(x[1]) * 16 + hexCharToInt(x[2]);

int hexCharToInt(char c)
{
    if (c >= '0' && c <= '9')    return c - '0';
    if (c >= 'a' && c <= 'f')    return c - 'a' + 10;
    if (c >= 'A' && c <= 'F')    return c - 'A' + 10;
    return -1;
}

I've also posted my raw data from various color samples as attachment. If I get a balancing matrix from a white sample, and apply those coefficients to my readings they still doesn't make any sense.
23042012580.jpg


Any advice would be much appreciated.
Thanks,
[h=3][/h]
1024 x 768 - 50K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-23 06:09
    ismalik,

    Welcome to the forum!
    Here is my code to get the output values and convert them to 0-255 range.

    That code will convert the ColorPAL output to its native 0 -1023 range. If your result is a byte, you will be losing the two msbs. IOW, 95 might well have been 95 + 256 or even 95 + 512.

    -Phil
  • ismailkismailk Posts: 2
    edited 2012-04-23 06:33
    ismalik,

    Welcome to the forum!



    That code will convert the ColorPAL output to its native 0 -1023 range. If your result is a byte, you will be losing the two msbs. IOW, 95 might well have been 95 + 256 or even 95 + 512.

    -Phil

    Ah, I see.
    Cant believe I've made such an elementary mistake.
Sign In or Register to comment.