[SciPy-User] Antwort: Re: scipy.interpolate.interp2d too many data values..

Andrew Straw strawman at astraw.com
Fri Sep 4 14:03:05 EDT 2009


markus.proeller at ifm.com wrote:
> >For interpolation of images that are specified on a regular grid,
> look at
> >scipy.ndimage, especially map_coordinates.
>
> Yes, that's what I was looking for. How do you actaully use it for a
> RGB image?
> I used the example from http://www.scipy.org/Cookbook/Interpolation
> but I don't understand how it works for 3-D coordinates.
> I want to apply the same remapping stored in y_new, x_new arrays with
> 2-D shape for the 3 channels. Until now I just understand like
>
> >>> coords = array([y_new, x_new])
> >>> r = map_coordinates(img_org[:,:,0], coords )
> >>> g = map_coordinates(img_org[:,:,1], coords )
> >>> b = map_coordinates(img_org[:,:,2], coords )
> >>> img = dstack((r,g,b))
>
> But it seems that it can be done shorter...
Here's an example Stefan van der Walt cooked up:

See lines 51-66, especially the "color band mapping" part of
http://bazaar.launchpad.net/~astraw/pinpoint/dev/annotate/head%3A/pinpoint/distortion.py




More information about the SciPy-User mailing list