How to crop brain dicom image so that only brain apperars in a rectangular box?

1 view (last 30 days)
I am having an image of brain in DICOM format. I wanted to cover in a bounding box so that outer area can be eliminated. I have tried the following code but its not working.
clear all;
close all;
clc;
X = dicomread('T2W_Brain.dcm');
imagesc(X, [0 1024]), colormap(gray), colorbar, axis image, axis off
imcrop(X).
Here, output is black screen.
Kindly suggest the suitable wayout.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jan 2019
The problem is the imcrop(X) call. When you pass in an image like you are, imcrop() is defined as displaying the image and then putting up a cropping tool. It displays the image by using imshow() with no parameters. Your data is uint16 that has a maximum of about 1624, so relative to the full uint16 range it is pretty much all black.
Calling imcrop() passing in an image does not use the active caxis value or the active colormap. Indeed in your situation where the axes is the only thing in the figure, the imshow() that gets called will delete the axes and create a new one.
The solution:
h = imagesc(X, [0 1024]), colormap(gray), colorbar, axis image, axis off
Y = imcrop(h);

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!