MATLAB: Seperating two different types of pixels

digital image processingImage Processing Toolboxmri

I have a medical dicom image. I want the following things to do:
1. To display the histogram of dicom image in a log scale to see all the pixels in the range.
2. To separate the pixels ( there are two types of pixels – one type corresponds to the fat tissue and the other type corresponds to the glandular tissue. The fat tissue pixels contain low energy x-ray/beams , and the glandular tissue pixels contains high energy beams.
how can I separate these two types of pixels
3. How can I count the pixels of these two types separately.
Can anyone please help me.

Best Answer

See my image segmentation tutorial : http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 to see how you can discriminate between the two classed based on intensity and size. You can use other characteristics too, depends on what is different between the two classes (fat and glands).
Here's histogram code:
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of original image', 'FontSize', 24);
xlim([0 grayLevels(end)]); % Scale x axis manually.
You can take the log of the counts before displaying, or else you can use logy() to display the original histogram on a log scale.