How to convert 3D to 4D images

조회 수: 22 (최근 30일)
mohd akmal masud
mohd akmal masud 2022년 2월 15일
댓글: mohd akmal masud 2022년 2월 15일
Hi all
I have image dicom as 3D as (attached). How to combine it all the slice to 4D?
anyone can help me?

채택된 답변

Simon Chan
Simon Chan 2022년 2월 15일
Try thw following:
[filename,pathname]=uigetfile('*.dcm','Select Files', 'MultiSelect', 'on');
Nz = length(filename);
for k = 1: Nz
imagedata = dicomread(fullfile(pathname,filename{k}));
if k == 1
[Ny,Nx] = size(imagedata);
rawdata = zeros(Ny,Nx,Nz);
end
rawdata(:,:,k) = imagedata; % Convert to 3D
end
Dimage = permute(rawdata,[1 2 4 3]); % Convert to 4D

추가 답변 (1개)

DGM
DGM 2022년 2월 15일
편집: DGM 2022년 2월 15일
If you have a volumetric image represented in a 3D array and you want to slice it on dim 3 and arrange each slice into a frame in a 4D image, you can do
B = permute(A,[1 2 4 3]);
If you want to slice on another dimension, just rearrange the first,second, and fourth elements of that vector in the call to permute().
EDIT:
A concrete example:
dirname = 'ZubalPhantomDicom';
dicomlist = dir(fullfile(pwd,dirname,'*.dcm'));
imstack = cell(numel(dicomlist),1);
for cnt = 1:numel(dicomlist)
imstack{cnt} = dicomread(fullfile(pwd,dirname,dicomlist(cnt).name));
end
% the image is currently a cell array of pages
% say we arrange the pages on dim3
imstack3 = cat(3,imstack{:});
% let's say we want to arrange the pages on dim4 instead
imstack4 = cat(4,imstack{:});
% let's say we wanted to take imstack3 and turn it into imstack4
imstack34 = permute(imstack3,[1 2 4 3]);
  댓글 수: 1
mohd akmal masud
mohd akmal masud 2022년 2월 15일
TQ Sir DGM and Simon Chan, Its work!!

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by