Bug in GetOptimalKernelWidth2D
Posted: 2007-06-09T09:54:41-07:00
When calling blur or gaussian blur (via Magick++), some radii cause problems because GetOptimalKernelWidth2D might not return a valid kernel width:
GetOptimalKernelWidth2D - gem.c line 239
It can return an even number, but
fx.c line 491
requires an odd number
Possible solution:
In gem.c:
The second "if" is needed in case the first one overshoot into another region whose image is even.
--Hector C
GetOptimalKernelWidth2D - gem.c line 239
Code: Select all
return((unsigned long) (MagickMax(2.0*radius+1.0,3.0)+0.5));
fx.c line 491
Code: Select all
if ((width % 2) == 0) ThrowImageException(OptionError,"KernelWidthMustBeAnOddNumber");
Possible solution:
In gem.c:
Code: Select all
{
double d_Radius = radius;
if ( (unsigned long) (d_Radius * 2.0 + 1.5) % 2 == 0 )
d_Radius += 0.5;
if ( (unsigned long) (d_Radius * 2.0 + 1.5) % 2 == 0 )
d_Radius -= 0.25;
return((unsigned long) (MagickMax(2.0*d_Radius+1.0,3.0)+0.5));
}
--Hector C