how to write loop for dicom image

6 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 1 月 4 日
コメント済み: Rik 2021 年 1 月 5 日
Hi all, i have 10 images start with I40.dcm to I130.dcm.
i try thid command, but failed. anyone can help me?
clear all
clc
P = zeros(256, 256, 10);
for K = 1 : 10
petname = sprintf('I%40d.dcm', K);
P(:,:,K) = dicomread(petname);
end
imshow3D(P)

採用された回答

Rik
Rik 2021 年 1 月 4 日
You can either list the file names, or properly create the file name:
%clear all
%clc
%^^^^ These are not needed, and especially clear all is a bad idea. Use clear or clearvars instead.
P = zeros(256, 256, 10);
for K = 1 : 10
K_file=30+10*K;
petname = sprintf('I%d.dcm', K_file);
P(:,:,K) = dicomread(petname);
end
imshow3D(P)
  4 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 1 月 5 日
hir Sir RIK,
If i want to resize my image from to 103 to 128, is it correct my coding?
clear all
clc
P = zeros(103, 103, 60);
for K = 1 : 60
K_file=30+10*K;
petname = sprintf('I%d.dcm', K_file);
P(:,:,K) = dicomread(petname);
P(:,:,K) = imresize(P(:,:,K),[128 128])
end
imshow3D(P)
but i got error
Rik
Rik 2021 年 1 月 5 日
You can first read the dicom image to a temporary variable. Then you can resize it and store it in P.
But are you sure you want to resize the slices? In general you don't want to do that while reading a scan.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by