Page 1 of 1

feedback on fix to motion-bur in IM 6.4.1-0

Posted: 2008-04-30T16:27:44-07:00
by fmw42
I have retested motion-blur under IM 6.4.1-0 Q16-hdri and it is now properly centered and is of uniform weight. Thank you very much for the fix.

However, I am very puzzled about how to make use of radiusxsigma parameters to achieve a motion blur of 15 pixels. I have used trial and error to achieve a close match to a 15x15 horizontal convolution filter, blur the following image and compare its profile. I am finding that to achieve a 15 pixel horizontal blur equivalent to the convolution, I either need to use 0x1.75+0 or 7x0+0. Neither of these parameters seems to fit the model of radiusxsigma. I would have expected 7.5x0+0 or 0x5+0 to work, but they do not closely match the 15x15 convolution. I was under the impression that if radius=0, then the width would be given by 3xsigma (in this case 3x5=15 and not 3x1.75). On the other hand, if I give it a radius=half of the width with sigma=0, then that should work. In that case radius=7.5 should achieve width=15, but I find that it is closer to radius=7 to get the same effect.

I have looked at the code for MotionBlurImage() and GetOptimalKernelWidth1D(), but am still puzzled, because the latter seems to be used by -blur and -gaussian-blur and the notes there say that width should be 3xsigma for radius=0.

On the other hand, I do see a comment in the header of GetOptimalKernelWidth1D() that the radius does not count the center pixel.

"radius: the radius of the Gaussian, in pixels, not counting the center pixel."

That would then explain why radius=7 gives a good match to a width=15 if the formula is width=2*radius+1. If this is correct, then a comment in the -motion-blur document would probably be appreciated by others and remind me later of this.

I would greatly appreciate it if someone could clarify for me how the motion-blur width is computed from the radiusxsigma and/or check if it is being properly computed, especially when radius=0.

This is not a high priority, but when you can, could you give me some feedback, so that I will know how to compute a motion blur of a given width and angle. In the mean time, I will go under the assumption that the best way to use -motion-blur is to give it a radius=(width-1)/2 and sigma=0.

Starting image:
Image

15x15 convolution
filt15="\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
"
convert square31.png -convolve $filt15 square31_IM_filt15.png
Image

Image

Results using radiusxsigma=0x1.75 (but I would have expected 7.5x0)
Image

Image


Results using radiusxsigma=7x0 (but I would have expected 0x5)
Image

Image

Thanks

Fred

Re: feedback on fix to motion-bur in IM 6.4.1-0

Posted: 2008-04-30T16:58:26-07:00
by magick
Sigma is only used if the radius is 0. With a non-zero radius, the kernel width is 2.0*ceil(radius)+1.0. Otherwise, the kernel width is computed from the sigma parameter by starting with a width of 3 and walking out until we drop below the threshold of one pixel numerical accuracy.

Re: feedback on fix to motion-bur in IM 6.4.1-0

Posted: 2008-04-30T18:27:56-07:00
by fmw42
Thanks. That helps a lot. I will stick with using radius and sigma=0 for motion-blur. It confirms my conclusions and is easier to compute and know what you are going to get as 0xsigma seems to be image dependent and does not work on this image as 3xsigma for the width (which seems to work well in -blur).

I appreciate the feedback and information about radius and sigma.