Question

I'm trying to perform morphology using Magick++ from a c++ program that I am writing. I can't find how to use the Morphology methods from c++ though.

I am trying to perform the following (we are converting from perl):

$q=Image::Magick->new;
$q->Read("blah.jpg");
$q->Morphology(method => 'Close', kernel => 'Diamond:4');

Can this not be done with just Magick++ ?

I have found this site, http://www.imagemagick.org/api/MagickCore/morphology_8h.html , but I am not sure if this is just the source code of ImageMagick itself.

Was it helpful?

Solution

It seems that Magick++ doesn't have the ability to do Morphology. Instead, the MagickCore library calls must be used (which means that you can't use the Magick++ classes anymore):

ExceptionInfo *e;
ImageInfo *ii;
Image *i;

e = AcquireExceptionInfo();
ii = CloneImageInfo((ImageInfo *) NULL);

strcpy(ii->filename, vm["input"].as<string>().c_str());
i = ReadImage(ii, e);
i = MorphologyImage(i, CloseMorphology, 3, AcquireKernelInfo("Diamond:4"), e);

It is more complicated, and there isn't any error handling like in Magick++, but it works.

To see everything available in the MagickCore library, take a look here: http://www.imagemagick.org/api/MagickCore/index.html

OTHER TIPS

zsalzbank part of the response you gave is incorrect "(which means that you can't use the Magick++ classes anymore)"

The Magick++ and MagickCore API's are designed to interact with each others.

You can convert like so ...

MagickCore::Image* img_core = img->image();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top