Code covered by the BSD License  

Highlights from
2D interpolation

5.0

5.0 | 1 rating Rate this file 36 Downloads (last 30 days) File Size: 3.74 KB File ID: #24183
image thumbnail

2D interpolation

by Andriy Myronenko

 

18 May 2009 (Updated 10 May 2011)

Fast 2D linear interpolation of scalar of vector valued 2D images.

| Watch this File

File Information
Description

 ZI = mirt2D_mexinterp(Z,XI,YI) interpolates 2D image Z at the points with coordinates XI,YI. Z is assumed to be defined at regular spaced points 1:N, 1:M, where [M,N]=size(Z).
If XI,YI values are outside the image boundaries, put NaNs in ZI.

The function is similar to Matlab's native
ZI = INTERP2(Z,XI,YI,'linear',NaN),
 but is much master. If Z is vector valued 2D image (3D array), then iteratively interpolates Z(:,:,1), Z(:,:,2),Z(:,:,3),.. etc. This works faster than to interpolate each image independently, such as
 ZI(:,:,1) = INTERP2(Z(:,:,1),XI,YI);
 ZI(:,:,2) = INTERP2(Z(:,:,2),XI,YI);
 ZI(:,:,3) = INTERP2(Z(:,:,3),XI,YI);
 
The extra speed gain is from the precomputation of coefficients for interpolation, which are the same for all images. Interpolation of a set of images is useful, e.g. for image registration, when one has to interpolate image and its gradients or for vector valued images such as RGB.

Limitations: only works for images on a regular grid, and only with linear interpolation method.

Don't forget to compile first:
mex mirt2D_mexinterp.cpp

Enjoy! See more at my homepage:
https://sites.google.com/site/myronenko/

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
15 Aug 2010 Harrison Woods

very useful for my applications, and very nice code! Thanks Andriy!

10 Jun 2011 Francisco Beron-Vera

Great job! (I couldn't get to work CUDA versions.) Thank you!

Please login to add a comment or rating.
Updates
10 May 2011

small fix

Tag Activity for this File
Tag Applied By Date/Time
interp2 Andriy Myronenko 19 May 2009 10:36:44
interpolation Andriy Myronenko 19 May 2009 10:36:44
2d interpolation Andriy Myronenko 19 May 2009 10:36:44
2d interpolation Martin 26 Apr 2010 07:14:43

Contact us at files@mathworks.com