Page 1 of 1

MagickFilterImage and non-square filters?

Posted: 2015-02-11T09:06:20-07:00
by Danack
Is it required to call MagickFilterImage only with square, odd-sized filters (e.g. 3x3) or would non-square values be allowed? e.g. 3x4

The function seems to give an error if even sized filters are used (e.g. 4x4) but doesn't give an error for 3x4 size. However the image generated is highly corrupted, with valgrind reporting a large number of errors.

Asking in this forum, as if it's not allowed, then I think it should be checked for, just like the check against even sizes, to prevent image corruption.

==5112== Conditional jump or move depends on uninitialised value(s)
==5112== at 0x12D3843B: FilterImageChannel (quantum.h:94)
==5112== by 0x129C419B: MagickFilterImageChannel (magick-image.c:3400)
==5112== by 0x126DBB45: zim_imagick_filter (imagick_class.c:11556)

Re: MagickFilterImage and non-square filters?

Posted: 2015-02-11T09:39:01-07:00
by snibgo
magick-image.c function MagickFilterImage calls effect.c function FilterImage, which contains:

Code: Select all

  if ((kernel->width % 2) == 0)
    ThrowImageException(OptionError,"KernelWidthMustBeAnOddNumber");
There seems to be no restriction on kernel height. There is code in there that is activated by debug, so you might try that.
Danack wrote:... if it's not allowed, then I think it should be checked for, just like the check against even sizes, to prevent image corruption.
Agreed. A developer would need to comment.

Re: MagickFilterImage and non-square filters?

Posted: 2015-02-11T16:45:52-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-6 Beta, available by sometime tomorrow. Thanks.