how to convert dicom image to png

6 次查看(过去 30 天)
Hi all,
i want to convert my dicom image to png image.
below my coding, but error. Anyone can help me?
[I, map]=dicomread('lung.dcm');
imwrite(I,map,'lung.png','png');
ERRORR!!!!
Error using imwrite>parse_inputs (line 628)
The colormap should have three columns.
Error in imwrite (line 440)
[data, map, filename, format, paramPairs] = parse_inputs(varargin{:});
CAN HELP ME?

采纳的回答

Image Analyst
Image Analyst 2021-1-23
I imagine you looked at what map was. Did that not give you any clue as to why it was not 3 columns? What was it? Maybe it's empty, in which case you'd not pass it in to imwrite.
  8 个评论
Image Analyst
Image Analyst 2021-1-24
You can't do that. You have to do it like I showed you - inside an "if" block. You can't convert a gray scale or indexed image to RGB if there is no colormap.
And for the gray scale image I assume you got that working already by doing what it told you and casting your image to uint8 with the im2uint8() or uint8() function
grayImage = im2uint8(grayImage);
imwrite(grayImage, outputFileName);
mohd akmal masud
mohd akmal masud 2021-1-24
oh i see..mean there is no map, then cannot convert it to RGB.
yes, for im2unit8 done.
thank you sir for your explanation. thank you so much.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by