MATLAB: How to convert dicom image to png

digital image processingimageimage acquisitionimage analysisimage processingImage Processing Toolboximage segmentation

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?

Best Answer

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.