Hello all,
I am currently working on an image processing project, using the DaVinci DM6437. Basically, the image processing within requires only the gray level values of the input image.
I modified the video_preview.c program a little, so that I am now able to capture a single frame by pressing the DIP switch, and displaying it on an external TV screen. So far so good (almost..), however, I cannot seem to find a proper way to create a gray level image, based on the YCbCr input image.
What I have done so far is a YCbCr2GrayscaleRowStack() function, that basically allocates a new array, half the size of the original input frame, and inserts the Y values one-by-one, simply by going over every other byte in the inputted frame.
The other function I created (inwhich probably the problem is somewhere) is called Grayscale2YCbCr() and is quoted here:
// CODE
// function: Grayscale2YCbCr; gets: current frame ptr, width and height of image (in pixels);
// returns: ptr to array of YCbCr valuess, length is width*height*2
unsigned char* Grayscale2YCbCr(unsigned char* CurrentFrame, int width, int height)
{
int i;
unsigned char* framePointer;
framePointer = (unsigned char*)malloc((width * height * 2)); // create a new array for the YCbCr gray image
for( i = 0; i < (width * height); i+=2)
{
*(framePointer + i) = 0x80; // every even byte has midpoint value
*(framePointer + (i+1) ) = *(CurrentFrame + i); // every odd byte gets the gray level value
}
return framePointer;
}
// END OF CODE
Both functions are very simple, and so is the basic idea. Now, the problem is the output image looks like that:
I have been searching a solution in this forum for quite some time now, and found this thread, with a resembling (but not the same) problem. I tried the size multiplying by two trick and it didn't work for. Notice that in my problem, I do receive the whole original information (besides the Cr & Cb bytes), only that it is displayed twice for some reason, and also leaving the bottom half of the screen blank (uninitialized most likely).
I will be very grateful for any sort of help, I hope i supplied enough information regarding the problem.
Thanks a lot, Yoav