-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcm2fmt.m
28 lines (26 loc) · 901 Bytes
/
dcm2fmt.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
clear all
clc
close all
[filename, pathname] = uigetfile('sample_image.dcm', 'Open DICOM Image');% Open only DICOM image
if isequal(filename, 0) || isequal(pathname, 0)
disp('Image input canceled.');
else
[X,MAP]=dicomread(fullfile(pathname, filename));
image8 = uint8(255 * mat2gray(X));
imwrite(image8,'myfile.jpg','jpg')%
input = menu('Choose a Format','bmp','jpg','tiff','gif','png');
if(input==1)
imwrite(image8,'myfile.bmp', 'bmp');% Save Image as bmp format
elseif(input==2)
imwrite(image8,'myfile.jpg', 'jpg');% Save Image as Jpeg format
elseif(input==3)
imwrite(image8,'myfile.tiff', 'tiff');% Save Image as tiff format
elseif(input==4)
imwrite(image8,'myfile.gif', 'gif');% Save Image as gif format
elseif(input==5)
imwrite(image8,'myfile.png', 'png');% Save Image as png format
else
disp('Unknown image format name.');
end;
imshow(image8, []);
end;