// clear the image
cvSet( IplImage* img, cvScalar(0,0));
// this will set each and every pixel to zero
Another simple method I recently became aware of:
cvZero( IplImage* img );
// clear the image
cvSet( IplImage* img, cvScalar(0,0));
// this will set each and every pixel to zero
cvZero( IplImage* img );
img = cvLoadImage(argv[1]);
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
for( i=0;i<height;i++ )
{
for( j=0;j<width;j++ )
{
for( k=0;k<channels;k++ )
data[i*step+j*channels+k] = 255 - data[i*step+j*channels+k];
}
}