Effacer les filtres
Effacer les filtres

How to interpolate 3-D data from a .mat file?

3 vues (au cours des 30 derniers jours)
spider_plantt
spider_plantt le 4 Août 2020
I have a 256x256x256 struct in a .mat file that I'm trying to interpolate using meshgrid and interp3. What I'm trying to do is slice the 3-D image so that it re-interpolates onto a given grid. My code is below and since I'm very new to this I'm essentially rehashing the interp3 example code. I keep getting an error right now on line 2 [X,Y,Z,V]=load('gm.mat'), reading "Insufficient number of outputs from right hand side of equal sign to satisfy assignment".
load('sphere.mat');
[X,Y,Z,V]=sphere;
[Xq,Yq,Zq]=meshgrid(29:9:141,29:9:141,29:9:141);
Vq=interp3(X,Y,Z,V,Xq,Yq,Zq);
figure
slice(Xq,Yq,Zq,V,120,85,120);
shading flat
  2 commentaires
KSSV
KSSV le 4 Août 2020
[X,Y,Z,V]=sphere;
should be
[X,Y,Z]=sphere;
spider_plantt
spider_plantt le 4 Août 2020
Can you clarify this error? It keeps cropping up.
Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.

Connectez-vous pour commenter.

Réponses (1)

Raunak Gupta
Raunak Gupta le 12 Août 2020
Hi,
From the question I understand you have the V data that is stored in the struct file as this is a 3D Image so only values will be stored of a particular (x,y,z) pixel. I think you need to know what the resolution of image is, like what is the spacing between adjacent pixel in each dimension. In that way you can construct the coordinates matrices X, Y, Z with that spacing using meshgrid.
If you see the example mentioned in the interp3 , the [X, Y, Z, V] = flow (10) return coordinate space in X, Y, Z and volume data in Z. All the matrices have same size.
So, you can probably create X,Y,Z as you created the Xq,Yq,Zq but with the actual spacing in the image dimesion between pixels. If you don’t know the spacing, then second syntax of interp3 mentioned here can also help.
Hope this clarifies!

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by