Lab1ColorFiltering
Color Filtering
There should be different objectives in manipulate an image. Image processing refers to ameliorate or “underline” specific information from such an image. Computer Vision refers to the fact of extract meaningful information from an image. The extracted information can later be used to other levels of reasoning. E.g. motion planning or collition avoidance.
Mission
INCLUDE IMAGES
In this Lab we like you to write an efficient program to visualize a pre-selected area of pixels
Starter Code
I) YUYV To COLOR (in this example we use the LEGO's blue
int yvyu_to_color(u32 width,u32 height,u8 *inptr,u8 *outptr) {
int w, h;
int r,g,b,y,u,v;
for( h = 0; h < height; h++ ) {
for( w = 0; w < width; w++) {
if ((inptr[0] >= 0x28) && (inptr[0] <= 0x3F) &&
(inptr[1] >= 0x79) && (inptr[1] <= 0x7F) &&
(inptr[2] >= 0x27) && (inptr[2] <= 0x39) &&
(inptr[3] >= 0x8E) && (inptr[3] <= 0xD2) )
{
outptr++;
(*outptr) = 0x77;
outptr+=2;
(*outptr) = 0xCE;
outptr++;
}
else
{
outptr++;
(*outptr) = 0x00;
outptr+=2;
(*outptr) = 0x00;
outptr++;
}
inptr += 4;
}
}
return 0;
}
II) YUYV to a Color Blob
int yvyu_to_colorblob(u32 width,u32 height,u8 *inptr,u8 *outptr) {
int w, h;
int r,g,b,y,u,v;
/* The new variables jump_w and jump_h are used
to create a window, and decrease the granularity.
In this example the windows is 2x2.
With jump=1, a 320x240 image takes 0.090792 sec.
With jump=2, a 320x240 image takes 0.023435 sec.
/*
int jump_w=2,jump_h=2;
for( h = 0; h < height; h+=jump_h ) {
for( w = 0; w < width; w+=jump_w) {
outptr+=(4*(jump_w-1));
if ((inptr[0] >= 0x28) && (inptr[0] <= 0x3F) &&
(inptr[1] >= 0x79) && (inptr[1] <= 0x7F) &&
(inptr[2] >= 0x27) && (inptr[2] <= 0x39) &&
(inptr[3] >= 0x8E) && (inptr[3] <= 0xD2) )
{
outptr++;
(*outptr) = 0x77;
outptr+=2;
(*outptr) = 0xCE;
outptr++;
}
else
{
outptr++;
(*outptr) = 0x00;
outptr+=2;
(*outptr) = 0x00;
outptr++;
}
inptr += 4;
}
outptr+=width*(jump_h-1);
inptr+=width*(jump_h-1);
}
return 0;
}
Links & References
The camera we are using outputs images on the YCbCr format.