[Numpy-discussion] nd_image.affine_transform edge effects

James Turner jturner@gemini....
Thu Mar 22 13:34:54 CDT 2007

The people at STScI put me in touch with Peter Verveer, the author of
nd_image. Unfortunately Peter is currently unable to maintain the code
(either in numarray or scipy), but he did send me some comments on the
problem discussed in this thread. Here's what he said:



Hi James,

Yes, it could be that you see some mirroring. Let me first explain what the mode 
options do:

If  you try to interpolate a value that falls outside of the boundaries, then 
that is done by either setting it constant (mode='constant') or by mapping to a 
position inside the boundaries, i.e. by mirroring, and then interpolating. So 
the mode argument really deals with extrapolating.

Problem is when  you are mapping a value that is inside the boundaries, but very 
close. Interpolation is done by splines which require that a window is placed 
around the point you are interpolating, and the result is calculated from the 
values inside that window. Thus, if you are close to the boundary, part of that 
window will fall outside the boundaries, and the algorithm must choose how to 
set the values outside the boundary. Ideally that would be done in the same way 
as above, i.e. you should have the choice if that is done by a constant value, 
or by  mirroring etc.

Unfortunately, the  spline algorithms that I use (references for the algorithm 
are in the manual) have an intrinsic mirroring assumption build in. Thus for 
interpolating values inside the boundaries, a mirror boundary is the only 
option. I did not figure out a way to modify the interpolation algorithms. 
Therefore, if you choose a mode different from mirroring, then you end up with 
small artifacts at the boundaries. Presumably these artifacts will get bigger if 
the order of spline interpolation you select is larger.

So, its not really a bug, its a undesired feature...

Cheers, Peter

More information about the Numpy-discussion mailing list