Converting from griddata3 to TriScatteredInterp

2 views (last 30 days)
Hi I need help converting a line in my code to TriscatteredInterp.
This is the original line:
ReconstructedUS(:,:,bg:en) = griddata3(TGridX, TGridY, TGridZ, US, RegularGridX, RegularGridY, RegularGridZ, 'linear');
I tried converting to TriscatterInterp using:
F = TriScatteredInterp(TGridX(:,:,:), TGridY(:,:,:), TGridZ(:,:,:), US(:,:,:), 'linear');
ReconstructedUS(:,:,bg:en) = F(RegularGridX, RegularGridY, RegularGridZ);
However I keep getting the error that the dimensions are in an invalid space.
Any help?

Answers (2)

Walter Roberson
Walter Roberson on 8 Nov 2011
Notice in the documentation,
F = TriScatteredInterp(X, V) creates an interpolant that fits a surface of the form V = F(X) to the scattered data in (X, V). X is a matrix of size mpts-by-ndim, where mpts is the number of points and ndim is the dimension of the space where the points reside (ndim is 2 or 3). The column vector V defines the values at X, where the length of V equals mpts.
But your TGridX is three dimensional, which is not a two dimensional array of size mpts x 2 or mpts x 3
So:
F = TriScatteredInterp( [TGridX(:), TGridY(:), TGridZ(:)], US(:), 'linear');
  4 Comments
Walter Roberson
Walter Roberson on 8 Nov 2011
I do not see any particular reason why you have bg and en in your ReconstructedUS array indices, but presumably it relates to the code you used to select the data.
I have no idea what the performance difference is between interp3 and TriscatteredInterp. My naive expectation would be that interp3 would be faster as it does not need to search to track which vertices are closest in order to do the interpolation.
When I saw your question I assumed it had to do with the question earlier today from someone whose data was not quite regular, but that turns out to be a different author: http://www.mathworks.com/matlabcentral/answers/19607-interp3-problem
Aman
Aman on 9 Nov 2011
Yes I am using bg/en to select a certain frame of sequences to reconstruct based on the raw ultrasound data. I just wanted to know if it was an acceptable line of code. Thanks for your help!

Sign in to comment.


Aman
Aman on 9 Nov 2011
Three different tries, still no results. Stumped as to why this isn't functioning properly.
??? Error using ==> TriScatteredInterp The input points must be a double array.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(:), TGridY(:), TGridZ(:)], US(:), 'linear');
??? Error using ==> TriScatteredInterp Input data point values have invalid dimension.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(:,:), TGridY(:,:), TGridZ(:,:)], US(:,:), 'linear');
??? Error using ==> TriScatteredInterp Input data point values have invalid dimension.
Error in ==> US_Reconstruction_v2b at 172 F = TriScatteredInterp([TGridX(), TGridY(), TGridZ()], US(), 'linear');
Any insight would be deeply appreciated!
  2 Comments
Walter Roberson
Walter Roberson on 9 Nov 2011
"a double array" means an array of datatype double precision. What data class are your TGrid* and US ?
Aman
Aman on 9 Nov 2011
TGrid* and US are both 510X2064X109 double

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!