[SciPy-User] 2D interpolation question

Shawn GONG SGONG@mdacorporation....
Wed Mar 17 11:18:12 CDT 2010


Thanks Zach for your quick reply.
I'll try map_coordinates then.

Shawn



-----Original Message-----
From: scipy-user-bounces@scipy.org on behalf of Zachary Pincus
Sent: Wed 3/17/2010 9:12 AM
To: SciPy Users List
Subject: Re: [SciPy-User] 2D interpolation question
 
> I'd like to do a 2D interpolation but not sure to use  
> scipy.ndimage.map_coordinates or scipy.interpolate   Your help is  
> greatly appreciated.
>
> I have a large evenly spaced 2D array (say 8000x8000). I need to  
> interpolate over a smaller-but-finer grid (say 500x500). The grid is  
> an evenly spaced rectangular, but it is rotated (i.e., with an angle).
>
> Which scipy function should I call?
>
map_coordinates is likely going to be the best and simplest for tasks  
like this that are basically "image resampling".

Basically, for each point in your output array, calculate the x,y  
position in the input array (as floating point), and put it into the  
input format described by the map_coordinates documentation (a  
2x500x500 array, IIRC). Then choose the order of spline interpolation:  
sound choices include 0 (nearest neighbor), 1 (linear), and 3 or 5  
(higher order). The higher-order splines will give "nicer looking"  
results on smooth patches, but are susceptible to ringing artifacts  
near sharp edges in the input array.

The rest should be self-explanatory, but if not, ask away.

Zach

PS. if you're doing a lot of resampling of the same input array, and  
speed for these operations is an absolute priority, and linear  
interpolation is acceptable, you could also consider do this on the  
graphics card with opengl. (I like pyglet for these tasks, but I bet  
pyCUDA would work as well?) You'd just have to slice the input texture  
a bit so as to not be over 4096x4096. 
_______________________________________________
SciPy-User mailing list
SciPy-User@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3683 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20100317/c0f1022c/attachment-0001.bin 


More information about the SciPy-User mailing list