Specifications
Intel
®
Image Processing Library Reference Manual
8-4
8
Example 8-1 Code Used to Produce Erosion in a Rectangular ROI
int example81( void ) { IplImage *imga, *imgb;
__try {
imga = iplCreateImageHeader(
1, 0, IPL_DEPTH_8U, "GRAY", "GRAY",
IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,
IPL_ALIGN_DWORD, 4, 4, NULL, NULL,
NULL, NULL);
if( NULL == imga ) return 0;
imgb = iplCreateImageHeader(
1, 0, IPL_DEPTH_8U, "GRAY", "GRAY",
IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,
IPL_ALIGN_DWORD, 4, 4, NULL, NULL,
NULL, NULL);
if( NULL == imgb ) return 0;
iplAllocateImage( imga, 1, 7 );
if( NULL == imga->imageData ) return 0;
// Create a hole
((char*)imga->imageData)[2*4+2] = 0;
// Border is taken from the opposite side
iplSetBorderMode( imga, IPL_BORDER_WRAP,
IPL_SIDE_ALL, 0 );
iplAllocateImage( imgb, 0, 0 );
if( NULL == imgb->imageData ) return 0;
// Erosion will increase the hole
iplErode( imga, imgb, 1 );
// Check if an error occurred
if( iplGetErrStatus() != IPL_StsOk ) return 0;
}
__finally {
iplDeallocate(imga,IPL_IMAGE_HEADER|IPL_IMAGE_DATA);
iplDeallocate(imgb,IPL_IMAGE_HEADER|IPL_IMAGE_DATA);
}
return IPL_StsOk == iplGetErrStatus();
}