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.

miror image in dm6437

hi,

as i understand (correct me if i'm wrong) the pixele it that format are stay in this order (y1 cb2 y2 cr2 y3 cb4 y4 cr4) and soo on, i still cant understand how can i modify the the image to work on each pixel for example, i want in my project to make a miror present a miror image - how shuld i work on these pixeles? or can it be some ting as i wrote here down.

void process_image_test( void* currentFrame,  int yRows, int xPixels)
{
  
    int xx = 0;
    int yy = 0;

            for( yy = 0; yy < (xPixels*yRows)*2; yy+=4 )
              {

                 *( ( (unsigned char*)currentFrame ) + yy ) = *( ( (unsigned char*)currentFrame ) - yy + (xx*yRows) - 2);
                if (yy == (xx*yRows))
                xx++;
               }
            for( yy = 1; yy < (xPixels*yRows)*2; yy+=2 )
              {

                 *( ( (unsigned char*)currentFrame ) + yy ) = *( ( (unsigned char*)currentFrame ) - yy + (xx*yRows));
                if (yy == (xx*yRows))
                xx++;
               }
            for( yy = 2; yy < (xPixels*yRows)*2; yy+=4 )
              {

                 *( ( (unsigned char*)currentFrame ) + yy ) = *( ( (unsigned char*)currentFrame ) - yy + (xx*yRows) + 2);
                if (yy == (xx*yRows))
                xx++;
               }

}

 

please correct where i wrong.

 

another question is states here

        for( xx = screenshift*2+1; xx < (yRows * xPixels)*2; xx+=2 )//operate only on luma
            {
               if( *( ( (unsigned char*)currentFrame ) + xx )  < lowThreshold*3 )
               {
                  //  Below threshold, lower the luma
                  *( ( (unsigned char*)currentFrame ) + xx ) = 0x09;
               }
               else if( *( ( (char*)currentFrame ) + xx ) >= lowThreshold*3 &&  *( ( (char*)currentFrame ) + xx )  < hiThreshold*3 )
               {
                  //  Between thresholds, set luma to a mid point
                  *( ( (unsigned char*)currentFrame ) + xx ) = 0x80;
               }         
               else
               {
                  //  Above threshold, raise the luma
                  *( ( (unsigned char*)currentFrame ) + xx ) = 0xFE;
               }
        }// End for Quantize

why the curen frame (that spose to be the luma) can get only these values?

0x00, 0x80, 0xfe     -     no matter what other values i will put there will be the same result as here.

 

thnks alot,

vadim

  • can some one help me please

  • are you trying to do a horizontal flip (mirror) or vertical flip (up-side down image) or both (upside down mirror)?  I do not believe you are doing any of these in the source code above.  For simplicity, lets consider a video 4x2 video buffer.  Originally, the pixels would look like

    1   2   3   4

    5   6   7   8

    or 1-2-3-4-5-6-7-8 in memory.  If you want a mirror, you want

    4   3   2   1

    8   7   6   5

    or 4-3-2-1-8-7-6-5 in memory

    a simple function such as

    int16 *pVideoBuffer = pointer_to_video_buffer   //16-bit pixels
    int16 *pMirror = pointer_to_mirrored_video_buffer   //16-bit  pixels
    int width = pixels_in_a_row
    int height = rows_in_video_frame
    int x,y,i = 0;

    for (y=1; y <= height; y++)
    {
       for (x=1; x <= width; x++)
       {
          pMirror + i*2 = pVideoBuffer + (y*width - x)*2;   //should work with pointer to types other than int16
          // alternatively  pMirror[i] = pVideoBuffer[y*width - x] since we are using int16
          i++;
       }
    }

    When you run the loop above, you will see that the new buffer (pMirror) will be populated as 4-3-2-1-8-7-6-5, which was our goal.  Anyway, I hope this helps.

  • Remember that if you plan on displaying your mirrored image you will need to maintain the color format.  So if your pixels are ordered y cb y cr (for the life of me, I can never remember what the actual order is =) ), you can see that if you exchange the last pixel in a row with the first pixel you will end up with cr y cb y, which will pretty much hose any attempt to display the mirrored image.  One way to solve this is to mirror each component individually (first y with last y, first cr with last cr, first cb with last cb).  I think that was what you were trying to accomplish with your code, but I agree with Juan that you did not accomplish your goal.

  • you are correct, I forgot to take into account the order of the cb and cr components, my bad.

  • im sorry for the ignorant of mine but i didn't understand what is the mistake in my original code,

    as you did i also tried to change the order as you did but i take in acount the order of the cb y cr. again it does not working

    the things that it doew is the following:

    ( the horizontal black  lines are from the camera and not the tv)

    http://il.youtube.com/watch?v=WzxkkFI-Xak

    as you can see first of how it flipt up.. why?

    the second is that it get only grayscale color?

    the third is that there are green and purple runing on the screen verticaly.

  • The main thing that caught my eye was that you appeared to be writing to the same buffer, so after the first half of the frame was flipped, the last portion would be lost. 

  • but it alwayes working on other pixales although its on the same buffer

  • What I meant is that it would appear that you are overwritting part of the original data in the buffer as you work through the buffer.  Suppose your buffer has following pixel order

    1-2-3-4-5-6-7-8

    say you want the following order in the end, 4-3-2-1-8-7-6-5.  If you work out of the same buffer, you will likely replace pixel 1 with pixel 4 first, so you end up with

    4-2-3-4-5-6-7-8 

    as you can see, information for pixel 1 was overwritten and now is gone forever, there is no temporary buffer to store this information.