[Numpy-discussion] nd_image.affine_transform edge effects

James Turner jturner@gemini....
Fri Mar 23 03:28:21 CDT 2007


Hi Zach,

 > further I'm sorry to have caused Peter to be further bothered about
 > this non-issue.

Don't worry -- I have let him know that we've probably figured it out.
I hope Stefan agrees.

 > I now (hopefully) understand that the spline "pre-filter", while
 > explicitly analogous to a traditional anti-aliasing pre-filter, is
 > actually computing the spline coefficients via a filtering-type
 > operation.

Ah, sounds like it's just calculating the weights for the specific
sample grids. That makes sense.

So, if you want a smooth result in the rotate_artifacts example, you
probably first want to apply a convolution as an anti-aliasing step
using one of the nd_image filter functions (eg. convolve or
gaussian_filter), then interpolate as before with the higher-order
spline. That ought to get rid of the artefacts if nd_image is indeed
doing the right thing. I think you figured out that much already.
Although not strictly band limited, I think a Gaussian with a sigma of
around 1 pixel should reduce the aliasing to just a couple of percent
(I did that calculation before in connection with my astronomy stuff).

I just tried adding the following line to the code snippet from ticket
213, before the line beginning "I_rot_1 =" and it looks to me like the
artefacts have gone (plays havoc with the colours though!). It's hard
to tell the difference between the 1st and 2nd order results, however,
even zooming right in.

I = ndi.gaussian_filter(I, 1.0, order=0, mode='constant', cval=0.0)

Hope I'm making sense; it's 4:20am here.

Cheers,

James.



More information about the Numpy-discussion mailing list