how to convert 4D into 3D?

25 visualizzazioni (ultimi 30 giorni)
mohd akmal masud
mohd akmal masud il 30 Lug 2022
Modificato: mohd akmal masud il 31 Lug 2022
Dear all,
the name file is LiverTS399.mat
how to convert it into 3D?
I tried use this command, but still 4D in workspace
load('LiverTS399.mat')
split = squeeze(cropVol);

Risposta accettata

Walter Roberson
Walter Roberson il 31 Lug 2022
split = reshape(cropVol, size(cropVol,1), size(cropVol,2), size(cropVol,3)*size(cropVol,4));
This would give you a 3D volume in which the 4th dimension has been spread out onto the third dimension.
or perhaps you want
split = squeeze(num2cell(cropVol, [1 2 3]));
This would give you a cell array in which each element was a 3D slice.
  1 Commento
mohd akmal masud
mohd akmal masud il 31 Lug 2022
Modificato: mohd akmal masud il 31 Lug 2022
this is correct
split = reshape(cropVol, size(cropVol,1), size(cropVol,2), size(cropVol,3)*size(cropVol,4));
thank you so much @Walter Roberson
but the real size is [184 192 152] but I got is [184 192 608]
I try use this one but got Error
split = reshape(cropVol, size(cropVol,1), size(cropVol,2), size(cropVol,3));
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that
dimension.

Accedi per commentare.

Più risposte (1)

Matt J
Matt J il 31 Lug 2022
If you mean you want the i-th 3D frame of the 4D data, then,
frame_i=cropVol(:,:,i)
  1 Commento
mohd akmal masud
mohd akmal masud il 31 Lug 2022
Modificato: mohd akmal masud il 31 Lug 2022
thank you @Matt J
I use
frame_i=cropVol(:,:,:,4)
then give what I want

Accedi per commentare.

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by