ImageMagick + Opencv

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
Xenith
Posts: 1
Joined: 2011-02-25T12:13:42-07:00
Authentication code: 8675308

ImageMagick + Opencv

Post by Xenith »

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.

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;
}
and the last thing, don't forget to make the cvImage parameter as a 4 channels something like this:

Code: Select all

IplImage* cvimg =  cvCreateImage(cvSize(...,...), IPL_DEPTH_8U, 4);
hope these tips help you :D
Post Reply