Tuesday, November 24, 2009

Invert an image in OpenCV

IplImage *input, *output;
cvXorS(input, cvScalar(255), output)

http://ioctl.eu/blog/2009/05/04/opencv_invert

openCV 8UC1 Error unsupported format

To fix change the dept of IplImage to 8 and change the nChannels to 1

something like .. .
IplImage *img;
img->depth = 8;
img->nChannels = 1;

Not correct way since the picture will be more stretch than the original
finding more correct way ...
http://osdir.com/ml/lib.opencv/2006-03/msg00760.html

IplImage *img; // Kept color image (image that nChannels > 1)
IplImage *dst = cvCreateImage(cvSize(img->width,img->height), 8, 1);
cvCvtColor(img, dst, CV_RGB2GRAY);