how to convert 5 dcm images to 5 png images

2 ビュー (過去 30 日間)
mohd akmal masud
mohd akmal masud 2021 年 1 月 27 日
コメント済み: mohd akmal masud 2021 年 2 月 5 日
Hi all, i have 5 dicom images. i want to convert it to png images.
clc
clear all
% Get a list of all files in the folder with the desired file name pattern.
myFolder = 'C:\Users\Akmal\Documents\MATLAB\Add-Ons\Functions\Region Growing\ct koh';
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for L = 1 : length(theFiles)
baseFileName = theFiles(L).name;
fullFileName = fullfile(theFiles(L).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
RZ(:,:,L)= dicomread(fullFileName);
end
% [RZ, map] = dicomread(fullFileName);
RZ11(:,:,L) = im2uint16(RZ(:,:,L) );
dcmImagei(:,:,L) = uint8(255 * mat2gray( RZ11(:,:,L) ));
imwrite(dcmImagei(:,:,L),'qqqmyGray.png');
BUT MY PROBLEM IS JUST ONE IMAGE PRODUCE. HOW ABOUT TO PRODUCE ANOTHER 4?

採用された回答

yanqi liu
yanqi liu 2021 年 2 月 1 日
clc; clear all; close all;
% Get a list of all files in the folder with the desired file name pattern.
myFolder = 'C:\Users\Akmal\Documents\MATLAB\Add-Ons\Functions\Region Growing\ct koh';
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for L = 1 : length(theFiles)
baseFileName = theFiles(L).name;
fullFileName = fullfile(theFiles(L).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
RZ(:,:,L)= dicomread(fullFileName);
RZ11(:,:,L) = im2uint16(RZ(:,:,L) );
dcmImagei(:,:,L) = uint8(255 * mat2gray( RZ11(:,:,L) ));
imwrite(dcmImagei(:,:,L), sprintf('qqqmyGray%d.png', L));
end
  1 件のコメント
mohd akmal masud
mohd akmal masud 2021 年 2 月 5 日
Great!! Its work. Thank you so much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by