形态学使用Magick ++ [英] morphology using Magick++
问题描述
我正在尝试使用Magick ++从我正在编写的c ++程序中执行形态学。我找不到如何使用c ++中的形态学方法。
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.
我正在尝试执行以下操作(我们从perl转换):
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');
这不能用Magick ++完成吗?
Can this not be done with just Magick++ ?
我找到了这个网站,
http://www.imagemagick。 org / api / MagickCore / morphology_8h.html ,
但我不确定这是否只是ImageMagick本身的源代码。
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.
推荐答案
似乎Magick ++没有能力做形态学。相反,必须使用MagickCore库调用(这意味着你不能再使用Magick ++类):
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);
它更复杂,并且没有像Magick ++那样的错误处理,但它有效。
It is more complicated, and there isn't any error handling like in Magick++, but it works.
要查看MagickCore库中的所有内容,请查看此处: http://www.imagemagick.org/api/MagickCore/index.html
To see everything available in the MagickCore library, take a look here: http://www.imagemagick.org/api/MagickCore/index.html
这篇关于形态学使用Magick ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!