This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to set Cb component of YCbCr equal to 0

Hi

I am working on skin detection on DM6437. I am getting CbCr component on my displayed image by using the code given below:-

void process_imagebw( void* currentFrame,  int yRows, int xPixels)
{
  
    int xx = 0;
   
                    for( xx = 1; xx < (yRows * xPixels)*2; xx+=2 )
            {

                  *( ( (unsigned char*)currentFrame ) + xx ) = 0x00;
               }

I am not able to figure out about how can I set Cb component to 0 for red skin detection as Cb is blue component. If I am using Wiki example      http://wiki.davincidsp.com/index.php?title=Accessing_pixels_in_a_frame_on_DM643x

then the sequence of YcbCr is Cb Y Cr Y Cb Y Cr Y Cb Y.. So is it possible to set Cb component to 0 by this method or any alternative method..

 

Thanks in advance

Jalwinder Pingal

  • The original function from the wiki example is below for reference, this function is leaving the Y values alone and setting the chroma values to the midpoint of 0x80, note that if you want a image that looks greyscale you want your color values to be in the middle not all 0:

    //make the image greyscale by setting all chrominance to 0x80
    void process_imagebw( void* currentFrame,  int yRows, int xPixels)
    {
       
        int xx = 0;
         
            for( xx = 0; xx < (yRows * xPixels)*2; xx+=2 )//just operating on the chroma
                {
     
                      *( ( (unsigned char*)currentFrame ) + xx ) = 0x80; //set all chroma to midpoint 0x80
                   } 
     
         
    } // End process_imagebw()

     

    The for loop starts with xx = 0 in this case so the loop only hits the chroma (Cb/Cr) values, in your case starting with xx = 1 will mean the loop is hitting the luma values (Y) (not sure why you have this?). The loop has xx+=2 so that you skip every other byte and only hit the chroma, or in your case satrting with 1 the luma. This being said if you wanted to only hit the Cb or the Cr values you would change the loop to use xx+=4 and you would start the loop with xx=0 or xx=2 to hit Cb or Cr, i.e. for( xx = 0 /* or 2 */; xx < (yRows * xPixels)*2; xx+=4). 

  • Hello Bernie.

    Thanks for your reply. 

    But I am still not able to set my blue (Cb) component to 0 so that my display only has red component. I tried your solution but it did not work as blue component is just changing colors and not going to zero. What hex value(e.g 0x00) should I used here to set Cb 0. Please guide me . Also is there any web document out there which gives hex values and their corrsoponding colors in Ycbcr ?

    Thanks for your time

    Jalwinder

  • Jalwinder Singh said:
    But I am still not able to set my blue (Cb) component to 0 so that my display only has red component. I tried your solution but it did not work as blue component is just changing colors and not going to zero. What hex value(e.g 0x00) should I used here to set Cb 0.

    I am not sure exactly what you are trying to do, if you just zero out the Cb component you would end up with an image that is probably mostly red and green, if you set Cb to 0x80 the midpoint than the image would be more like there was no Cb influence at all (i.e. the effect would be like you would see if you disconnected the Cb cable from a DVD player hooked up with component. I have not tried that many combinations with myself to properly describe what it would really look like, bit if you want to set Cb to 0 than you are already doing it, I am just not sure that is what you want.

    Jalwinder Singh said:
    Also is there any web document out there which gives hex values and their corrsoponding colors in Ycbcr ?

     

    This site here is kind of the inverse of what you were asking for, you can pick a color and see what the YCbCr value would be for it, it can give you a better idea of what color effects you should expect by tweaking the values in a YCbCr image.

  • Hello Bernie.

    Thanks for your reply again.

    I think there is no possibility on DM6437 board to keep only Cr component on display. If that's the case then I have to apply edge detection on my display frame to filter out skin regions. Can you please tell me which IMGLIB function is right one to use for edge detection? 

     

    thanks

    Jalwinder