0

i'm working with openCV and i'm trying to convert an image into a single channel image. i loaded the image with: IplImage* img=cvLoadImage(“abc.pbm”); i wasnt sure how i was supposed to convert to single channel so i used:

IplImage* temp = cvCreateImage(cvGetSize(img), img->depth, 1); cvSetImageCOI(img, 1); cvCopy(img, temp);

it compiles fine, but it crashes during runtime saying "opencv error: assertion failed (src.channels()==dst.channels()) in unknown function ..."

can anyone help me out?? can i get any better suggestions to convert to single channel image?

2 Answers 2

4

you could also load it as greyscale:

IplImage* img=cvLoadImage(“abc.pbm”,CV_LOAD_IMAGE_GRAYSCALE);
2

You need to use cvCvtColor().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.