Converting from griddata3 to TriScatteredInterp

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?

답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 8일

1 개 추천

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

Aman
Aman 2011년 11월 8일
Hi Walter.
Thanks for the reply. I will test out the tweak tomorrow. I just wanted to know if the final line for the ReconstructedUS = F(...) is still acceptable or if I have to change it?
Thanks!
Aman
Aman 2011년 11월 8일
My program is eating up 18GB with griddata3 right now. Basically I am trying to interpolate 2D freehand Ultrasound images into a 3D image. So the vector sizes for the grids are almost 510X 2056X109 each and the frames are huge. It is taking me forever to interpolate and get anything, and often the pc hangs. So I was wondering if TriscatteredInterp would make a difference?
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 2011년 11월 9일
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!

댓글을 달려면 로그인하십시오.

Aman
Aman 2011년 11월 9일

0 개 추천

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

"a double array" means an array of datatype double precision. What data class are your TGrid* and US ?
Aman
Aman 2011년 11월 9일
TGrid* and US are both 510X2064X109 double

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2011년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by