Dicom file not displaying properly.

조회 수: 5 (최근 30일)
Warid Islam
Warid Islam 2022년 11월 15일
댓글: Warid Islam 2022년 11월 18일
I am trying to read and display dicom(.dcm) file in matlab and save it later. However, the file is not displaying properly. Please find my code below:
info=dicominfo("IMG-0012-00218.dcm");
I=dicomread(info);
figure, imshow(I,[])
h = drawfreehand; %draw something
M = ~h.createMask();
I(M) = 0;
imshow(I,[]);
imwrite(I,'Image1.png','mode','loseless')
I am unable to attach the .dcm file here as it is not allowing me to do it. I am getting the image below which is not correct. I want the image to be displayed in the way defined in 'IMG-0012-00218.png'.

답변 (1개)

Harsha
Harsha 2022년 11월 18일
Hi Warid Islam
To get the output as shown in IMG-0012-00218.png you have to change the window level in the raw data.
Refer to this MATLAB answer by Simon Chan to resolve your issue.
  댓글 수: 1
Warid Islam
Warid Islam 2022년 11월 18일
Thank you for your response. I have a query. Your code solves my above question. I want to do further operation on that image. I want to manually segment the image and save the resultant image in the .png format. I tried the code below. However, I didn't get the desired result.The saved image looks like below.
I=dicomread('IMG-0012-00219.dcm');
metadata = dicominfo('IMG-0012-00219.dcm');
WC = metadata.WindowCenter; % original [40; 40]
WW = metadata.WindowWidth;
figure, imshow(I,[WC(1)-WW(1), WC(1)+WW(1)]);
h = drawfreehand; %draw something
M = ~h.createMask();
I(M) = 0;
imshow(I,[WC(1)-WW(1), WC(1)+WW(1)]);
imwrite(im2double(I),'Image3.png','mode','loseless')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by