Specifications
Image Creation and Access
4-39
4
Example 4-7 Using the Function iplGetPixel()
int example_1001( void ) {
char pixel[4]; /// buffer to get pixel data
/// roi to set different data in different channels
IplROI roi={0,0,0, 4,4 };
IplImage *img = iplCreateImageHeader(
4, 4, IPL_DEPTH_8U, "RGBA", "BGRA",
IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,
IPL_ALIGN_DWORD, 4, 4, &roi, NULL,
NULL, NULL);
/// alpha-channel will be 4
iplAllocateImage( img, 1, 4 );
roi.coi = 1;
iplSet( img, 1 );
roi.coi = 2;
iplSet( img, 2 );
roi.coi = 3;
iplSet( img, 3 );
iplGetPixel( img, 0,0, pixel );
iplDeallocate( img, IPL_IMAGE_ALL & ~IPL_IMAGE_ROI );
return IPL_StsOk == iplGetErrStatus();
}