Be the first to rate this file! 31 downloads (last 30 days) File Size: 3.52 KB File ID: #24183

2D interpolation

by Andriy Myronenko

 

18 May 2009

Code covered by BSD License  

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

Download Now | 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:
http://www.bme.ogi.edu/~myron/

MATLAB release MATLAB 7.4 (R2007a)
Zip File Content  
Other Files license.txt,
mirt2D_mexinterp.cpp,
mirt2D_mexinterp.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com