[Numpy-discussion] nd_image.affine_transform edge effects
Stefan van der Walt
stefan at sun.ac.za
Fri Mar 16 02:48:38 EDT 2007
Hi James
On Thu, Mar 15, 2007 at 06:01:55PM -0400, James Turner wrote:
> >Code snippets to illustrate the problem would be welcome.
>
> OK. I have had a go at producing a code snippet. I apologize that
> this is based on numarray rather than numpy, since I'm using STScI
> Python, but I think it should be very easy to convert if you have
> numpy instead.
>
> What I am doing is to transform overlapping input images onto a
> common, larger grid and co-adding them. Although I'm using affine_
> transform on 3D data from FITS images, the issue can be illustrated
> using a simple 1D translation of a single 2D test array. The input
> values are just [4., 3., 2., 1.] in each row. With a translation of
> -0.1, the values should therefore be something like
> [X, 3.1, 2.1, 1.1, X, X], where the Xs represent points outside the
> original data range. What I actually get, however, is roughly
> [X, 3.1, 2.1, 1.0, 1.9, X]. The 5th value of 1.9 contaminates the
> co-added data in the final output array. Now I'm looking at this
> element-by-element, I suppose the bad value of 1.9 is just a result
> of extrapolating in order to preserve the original number of data
> points, isn't it? Sorry I wasn't clear on that in my original post
> -- but surely a blank value (as specified by cval) would be better?
I'd like to confirm that you see the same results when running your
script:
[[ 4. 3. 2. 1.]
[ 4. 3. 2. 1.]]
[[-1. 3.12520003 2.11439991 1.01719999 1.87479997 -1. ]
[-1. 3.12520003 2.11439991 1.01719999 1.87479997 -1. ]]
[[-1. 3.0996666 2.0999999 1.34300005 1.90033329 -1. ]
[-1. 3.0996666 2.0999999 1.34300005 1.90033329 -1. ]]
Cheers
Stéfan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jturner.py
Type: text/x-python
Size: 686 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070316/4c6fc7f6/attachment.py>
More information about the NumPy-Discussion
mailing list