XorS Function Example
In the example below, the program computes bitwise logical XOR of a constant and
the pixel values of an RGB image. To do this, the program calls
the library function iplXorS().
You can run the example either from the applet on this page or from the command line:
>arithm -t3 -v<value>
The source:
int xors( int value ) { const int width = 256, height = 100; char *rgbmode = "RGB", *rgbseq = "BGR"; IplImage *src=NULL, *dst=NULL; char title[32]; __try { /// create 3 channels source image with plane data order src = iplCreateImageHeader( 3, // 3 channels 0, // no alpha channel IPL_DEPTH_8U, // data type is uchar rgbmode, // color model rgbseq, // channel sequence IPL_DATA_ORDER_PLANE,// channel arrangement IPL_ORIGIN_TL, // top left orientation IPL_ALIGN_DWORD, // 4 bytes align width, height, // image width and height NULL, NULL, // no ROI, no mask ROI NULL, NULL); // image ID, not tiled /// create 3 channels destination image dst = iplCreateImageHeader( src->nChannels, src->alphaChannel, src->depth, rgbmode, rgbseq, src->dataOrder, src->origin, src->align, width, height, NULL, NULL, // no ROI, no mask ROI NULL, NULL); // image ID, not tiled if( !src || !dst ) return -1; // allocate memory for image according to header specifications, // don't initialize pixel values. To initialize pixel values // to value, set second parameter to 1 and third parameter to // desired number iplAllocateImage( src, 0, 0 ); iplAllocateImage( dst, 0, 0 ); if( !src->imageData || !dst->imageData ) return -2; /// create a color image if( Good != GenerateRamp8uC3P( src )) return -3; /// execute XOR operation with using IPLib function iplXorS( src, dst, value ); /// show source and destination images ipView( src, " source img", !is_modal ); sprintf( title, " iplXorS img^%d(0x%02x)", value, value ); ipView( dst, title, is_modal ); } __finally { iplDeallocate( src, IPL_IMAGE_ALL ); iplDeallocate( dst, IPL_IMAGE_ALL ); } return 0; }
* Legal Information © 1998-2000, Intel Corporation