[Numpy-discussion] nd_image.affine_transform edge effects

Zachary Pincus zpincus@stanford....
Thu Mar 22 14:07:55 CDT 2007

Hi James,

Would it be possible to ask Peter if he knows anything that could  
help us resolve scipy ticket 213 ( http://projects.scipy.org/scipy/ 
scipy/ticket/213 )?

The basic issue is that ndimage.spline_filter seems to introduce  
nasty ringing artifacts, which make all of the geometric transforms  
(affine_transform included) perform very badly. Examples of these  
artifacts can be seen in the attachments to this ticket:


If Peter has any suggestions at all as to what's happened, that would  
be very helpful. Hopefully this won't be too much of an imposition,  
but these problems with the spline prefiltering are really hampering  
ndimage, so hopefully it will be worth it.


Zach Pincus
Program in Biomedical Informatics and Department of Biochemistry
Stanford University School of Medicine

On Mar 22, 2007, at 11:34 AM, James Turner wrote:

> 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:
> James.
> -----
> 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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list