4.0

4.0 | 2 ratings Rate this file 30 Downloads (last 30 days) File Size: 391.57 KB File ID: #21702
image thumbnail

3D Volume Interpolation with ba_interp3: Fast interp3 replacement

by Brian

 

09 Oct 2008 (Updated 09 Oct 2008)

Faster Replacement for interp3

| Watch this File

File Information
Description

ba_interp3 is a fast interpolation routine for 3D volumes. It can be used as a drop in replacement for matlabs interp3 function. It supports nearest neighbour, tri-linear, and tri-cubic interpolation.

Restrictions: The only restriction is, that the data has to be on a regularly spaced grid (i.e. coming from meshgrid.

Enhancements: The first advantage of ba_interp3 is that it is a lot faster.
ba_interp3 is up to 10 times faster than matlabs interp3 in realistic scenarios

Additionally, it can interpolate layered data. If you interpolate a matrix of size MxNxO x L1xL2x...xLk then each of the L1*L2*...*Lk layers is interpolated simultaneously. Think of this as in RGB images, where there would be a single additional dimension of size three.
An volume of 3x3 Matrices (i.e. the volume derivative) would have two additional dimensions of size three.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Image Interpolation (ba_interp2)

MATLAB release MATLAB 7.6 (R2008a)
Other requirements mex compiler
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
15 Feb 2009 Patrik

Great job, but I cannot compile!
The error is:

lcc preprocessor error: C:\ba_interp3\ba_interp3.cpp:62 Could not find include file <iostream>

What's the problem? Is it possible for you to include a compiled version for 32bit windows? Any help appreciated!

09 Apr 2010 Nicholas

In order to compile for Windows using VS 2005 Professional and the C90 library, I had to change 'round(x)' to 'int(x+0.5)' and modify the string comparison terms as my compiler couldn't handle the 'string1 == string2' statements. Now it works well.

18 Mar 2011 vick Audi

Hi Nicholas, could you please let me know what are those changes you made. I'm getting exactly the same error.

I'm a novice in C++ . I got rid of the round error by search-replace "round(" to "int(" but don't know how to fix the == error.

Thanks in advance for your input

08 Sep 2011 Hemal Naik

Linear interpolation is faster and cubic is much faster, However the slice shown has more data then what we usually get by using matlab function Interp3.
For some applications you might want to have same looking slice but much faster, I customized it for my application, cubic is almost 60%-70% faster then intep3 with mri data set of matlab.
Very cool contribution, thanks for uploading this :-)

20 Oct 2011 David Johnson

When I use mex -largeArrayDims to compile this function, the results are wrong (all zero). It works OK without this switch, though -largeArrayDims will probably become mandatory soon!

Matlab R2009a, Visual Studio 2008 SP1, Win7 x64 bit Enterprise.

Anyway, I really appreciate your work. Saved me a lot of time from coding this myself!

Please login to add a comment or rating.
Updates
16 Jan 2009

Bugfix to Documentation

Tag Activity for this File
Tag Applied By Date/Time
filtering Brian 22 Oct 2008 10:23:25
interp3 Brian 22 Oct 2008 10:23:25
interpolation Brian 22 Oct 2008 10:23:25
nearest neighbour Brian 22 Oct 2008 10:23:25
nearest neighbor Brian 22 Oct 2008 10:23:25

Contact us at files@mathworks.com