Seperating two different types of pixels

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.

 Accepted 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.

8 Comments

Dear Image Analyst
Thank you for your valuable help. I found your threshold technique in web and also I found it to be very helpful in separating low photon energy absorber -fat tissue ( appears at lower gray level range in histogram) and high photon energy absorber glandular tissue ( appears at higher gray level range in histogram). I am using the original dicom image histogram in your threshold template with 65535 gray levels. Now the problem is :
1. There are some overlapping regions where fat tissue pixels overlapped with glandular tissue pixels. Is there anyway to mark them separately with different colors in histogram?
2. Is there any other way to separate the overlapping regions completely so that I can use the sliders to put bar in between them?
please help me and once again thank you for your wonderful adjustable thresholding technique.
1. You can plot two sets of bars on the same plot, each with a different color.
2. Not sure what this means. Where is the bar going? On the bar chart or on the image? You can put a vertical bar on the plot with the line() command and ylim()
yl = ylim()
line([x, x], [0, yl(2)]);
Dear Image analyst. Thanks. I am writing it clearly---
1. In your threshold template , I am using log scale to adjust a threshold for separating fat tissue with glandular tissue. some pixels are overlapped in histogram ( they are at a gray level which can be fat tissue pixels or glandular tissue pixels. what should I do so that overlapped pixels are separated according to their characteristics as fat tissue (which are usually at low gray level range) and glandular tissue- (which are usually at higher gray level range) showing different colors? what command should I use in command window or what change should I make in your threshold.m file to do that?
please help
If a pixel of a certain gray level can be of either gland or fat type, then you need to process it differently since just a simple threshold can't do it. One way is to threshold first, and then use K nearest neighbors to post process it. Just scan the thresholded image and if more of the neighbors are of a certain type, then classify the pixel as that type also (basically a median filter). You can also do more sophisticated ad hoc things to tweak it very specifically to your situation.
Dear Image Analyst
Thanks a lot for your valuable advice. I will try to do as you advised. I would come back in case I face problems. thanks again.
Dear Image analyst
As a follow up of my previous question of separating fat tissues with glandular , I have adjusted the threshold to separate the pixels into two types , the pixels above threshold value are considered as glandular tissue pixels , whereas the pixels below the threshold are considered as fat tissue pixels . but I am not sure whether my threshold value is correct or not as there could be some pixels in overlapped regions either of fat type or glandular type. To make sure about these pixels , you advised to go for knn classification after thresholding. now I have already threholded with your famous thresholding template , and also have created a data array that contains pixels ( above threshold) , pixels ( below threshold), type 1 ( fat tissue) and type 2 ( glandular tissue , a total of 4 columns or 256X4 data matrix.
my questions
1. what will be my training data sets for knn classification? what will be my test data sets and species. if I consider the pixels above threshold as training data sets , I am already passing these pixels as confirm glandular type. will it be correct? please advise me.
2. after classifying using knnclassifier function, how can I interpret the results
please help me
thanks a lot in advance
There is no training set. You make a first guess at thresholding. Then you make a second pass with a scanning window. You divide the pixels in the window into three classes: (1) nebulous region where you don't know if it's fat for gland, (2) clearly fat based on how far their gray levels are away from the threshold, and (3) clearly gland. Then in that window, if the central pixels is (1), then you see if there are more (2) or more (3). Whichever class owns more pixels in the window, you assign the uncertain central pixel to that class. Does that make sense? "k" is just a sliding value that where you can adjust the relative proportions in each class before assigning the pixel. Like it must have 6 of the pixels be gland, or 2 or whatever. If you go with simple majority and a 3x3 window, and all 8 neighbors are either class 1 or 2, then k = 5. Make it simple and just go with the majority. If there is no majority, then enlarge your window temporarily until you do get a majority.

Sign in to comment.

More Answers (1)

Ruhul Amin
Ruhul Amin on 15 Apr 2014
Edited: Ruhul Amin on 15 Apr 2014
Dear Image Analyst
Thanks a lot for your kind help . If I use a 3X3 window as a median filter to scan the image, then how can I separate the three pixel classes and how to calculate the pixel no.for different classes.
I have attached the binary image .
Could you please give me some demo codes so that I can proceed with the right steps?

Categories

Find more on Medical Physics in Help Center and File Exchange

Asked:

on 30 Mar 2014

Edited:

on 15 Apr 2014

Community Treasure Hunt

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

Start Hunting!