Segmentation not working on Dicom images

3 views (last 30 days)
Warid Islam
Warid Islam on 22 Nov 2022
Commented: Warid Islam on 29 Nov 2022
This is related to a previous question I asked before.
I want to manually segment tumors from Dicom images. I tried the code below but I get a greyish image.
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)]);
The segmentation works fine, but the image is greyish which is not desirable. Any suggestions would be appreciated.
Warid Islam
Warid Islam on 29 Nov 2022
Hi @DGM,
It worked. Thank you very much.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 22 Nov 2022
I'm not sure what you mean by the image looks greyish. It looks like the masked blob in the middle has the full dynamic range. Do you just want to make the gray background be black? Like (untested)
grayMask = grayImage == grayImage(1,1);
grayMask = bwareafilt(grayMask, 1);
grayImage(grayMask) = 0;
imshow(grayImage, []);
Image Analyst
Image Analyst on 28 Nov 2022
Please attach the original gray scale image and the segmented (binary) image (the mask image).

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!