Storing a surface slice in a .mat file and plotting the stored slice

4 vues (au cours des 30 derniers jours)
Hans Martin
Hans Martin le 16 Oct 2020
Commenté : Ameer Hamza le 16 Oct 2020
Hi,
I use the slice function in matlab to slice through an echocardiopgrahic volume. As i create several slices from the volume, i want to increase the speed of my function. I want to create all the slices I want to plot (180 x 30ish slices) and store them somewhere (.mat or something simmilar). Then I want to be able to extract one of the slices and plot it. Here is what i want to do:
create several slices s,s1,s2....
s=slice(X,Y,Z,vol,X_1,Y_1,Z_1,'linear');
s1=slice(X,Y,Z,vol,X_2,Y_2,Z_2,'linear');
s2..
save(s,s1,s2....)
If i want to plot s2:
plot(s2)
I know that it will take some time to store all the slices, but then i omit to use the slice function everytime i want a new slice. I have experienced that the interp3 function is rather slow. I do not want to store them as a image, but i want the surface structure to be the same.
Is this possible?

Réponse acceptée

Ameer Hamza
Ameer Hamza le 16 Oct 2020
Modifié(e) : Ameer Hamza le 16 Oct 2020
Why not just save the .fig files. See savefig(): https://www.mathworks.com/help/matlab/ref/savefig.html
Alternatively, you can also save fig handle in a .mat file, but that is not an recommended approach.
And if you really want to save the handle of slice objects in a .mat file then you can replot then as shown below
Save a slice object
s = slice(X,Y,Z,vol,X_1,Y_1,Z_1,'linear');
save('slices.mat', 's');
Then load them like this
data = load('slices.mat');
s = data.s;
ax = axes();
hold(ax);
view(3);
copyobj(s, ax);
  4 commentaires
Hans Martin
Hans Martin le 16 Oct 2020
amazing. Thank you!
Ameer Hamza
Ameer Hamza le 16 Oct 2020
I am glad to be of help!

Connectez-vous pour commenter.

Plus de réponses (1)

KSSV
KSSV le 16 Oct 2020
You save all the slices into a cell and save them into .mat file.
S = cell(N,1) ;
S{1} = slice(X,Y,Z,vol,X_1,Y_1,Z_1,'linear');
S{2} = slice(X,Y,Z,vol,X_2,Y_2,Z_2,'linear');
Now you can save S alone which is a cell into a .mat file.
  3 commentaires
KSSV
KSSV le 16 Oct 2020
You save the required X, Y, Z also,,,
Hans Martin
Hans Martin le 16 Oct 2020
Ok, but which function can i use to plot one specific surface? Something simmilar to plot3(X,Y,Z, s{1})?
If i use s=slice .. the slice is plotted. But when i store them, the s is only a surface structure. And i want to extract one surface and plot that surface from the .mat file.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by