Page 1 of 1
Migrate convolveImage from IM 6 to IM 7
Posted: 2017-04-01T00:35:04-07:00
by NoRulez
Hello,
I've some problems to migrate a used function (convolveImage) from IM 6 to IM 7.
The old function requires a matrix but the new requires some KernelInfo stuff. I don't know how to fill these up
Please, could someone help
Thanks in advance
Re: Migrate convolveImage from IM 6 to IM 7
Posted: 2017-04-01T00:54:55-07:00
by dlemstra
This is how we do it in Magick++
Code: Select all
void Magick::Image::convolve(const size_t order_,const double *kernel_)
{
KernelInfo
*kernel_info;
GetPPException;
kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
kernel_info->width=order_;
kernel_info->height=order_;
kernel_info->x=(ssize_t) (order_-1)/2;
kernel_info->y=(ssize_t) (order_-1)/2;
kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
order_*sizeof(*kernel_info->values));
if (kernel_info->values != (MagickRealType *) NULL)
{
MagickCore::Image
*newImage;
for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
kernel_info->values[i]=kernel_[i];
newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
replaceImage(newImage);
}
kernel_info=DestroyKernelInfo(kernel_info);
ThrowImageException;
}
Hope this helps you.