ImageMagick + Opencv
Posted: 2011-02-25T12:38:04-07:00
at first sorry for my bad English!
we know that one of the richest library for image manipulating is ImageMagick, but its document specially in Magick++ is not as rich as its library. by the way, this is my first experience to use ImageMagicK and Opencv. if you want to convert from IplImage to Image and vice versa, just put these two funtion inside you source file.
and the last thing, don't forget to make the cvImage parameter as a 4 channels something like this:
hope these tips help you
we know that one of the richest library for image manipulating is ImageMagick, but its document specially in Magick++ is not as rich as its library. by the way, this is my first experience to use ImageMagicK and Opencv. if you want to convert from IplImage to Image and vice versa, just put these two funtion inside you source file.
Code: Select all
Image Ipl2Magick(IplImage* iplImage)
{
Image mgk(iplImage->width, iplImage->height, "BGR", CharPixel, (char *)iplImage->imageData);
return mgk;
}
Code: Select all
void Magick2Ipl(Image magicImage, IplImage* cvImage)
{
int width= magicImage.size().width();
int height = magicImage.size().height();
byte* blob= new byte[cvImage->imageSize];
magicImage.write(0,0, width, height, "BGRA", MagickCore::CharPixel, blob);
memcpy(cvImage->imageData, blob, cvImage->imageSize);
delete [] blob;
}
Code: Select all
IplImage* cvimg = cvCreateImage(cvSize(...,...), IPL_DEPTH_8U, 4);