Labeling objects in grayscale image in matlab

15 views (last 30 days)
Safaa
Safaa on 27 Sep 2012
Answered: julian tuyin on 28 Oct 2016
Hi all:
I need to label specific objects in grayscale histopathological image using matlab. This should be done without converting the image into binary image. Labeling is based on the color of those objects which is dark grey Labeling those objects aims mainly to calculate the size of each of them. Labeled objects with a size less than a specific size will be colored with red.
I have tried to apply bwlabeln function, but it is used to find connected components in binary image. Please I need a function or piece of code that could perform the described above. I can send the histopathological image to persons interested in the described problem
Regards,
Safa'a

Answers (3)

Hossein  Khaki
Hossein Khaki on 27 Sep 2012
Dear Safa
As I understood, you want to label some image with dark, gray and red. You can send me your image (<mailto:hsnkhaki@yahoo.com hsnkhaki@yahoo.com>). I can help you then.
Good Luck Hossein
  1 Comment
Safaa
Safaa on 28 Sep 2012
Edited: Safaa on 28 Sep 2012
Ok, I will send you the image with some clarification. Many thanks for your help.

Sign in to comment.


Image Analyst
Image Analyst on 27 Sep 2012
I don't think you know what labeling is. Connected components labeling works on binary images. So first you need to do something to get a binary image, called segmentation, that identifies all the blobs in your image. For example let's say you have bright gray and dark gray blobs on a medium gray background and you'd like to measure both the dark gray blobs, and the bright gray blobs. You do segmentation (for example thresholding) to get two binary images, one that has identified the dark gray blobs, one that has identified the bright gray blobs. Then you label each, and pass each labeled image into regionprops() to get the measurements for that type of blob. Labeling gives a unique ID number to each connected group of pixels - so this is dark blob #1, and that is dark blob #2, and that blob over there is dark blob #3. Same thing for the bright image. Something like this:
darkBlobs = grayImage < 50; % Find dark things.
labeledDark = bwlabel(darkBlobs);
darkMeasurements = regionprops(labeledDark, 'Area', 'Perimeter');
brightBlobs = grayImage > 200; % Find bright things.
labeledBright = bwlabel(brightBlobs);
brightMeasurements = regionprops(labeledBright, 'Area', 'Perimeter');
  3 Comments
Image Analyst
Image Analyst on 28 Sep 2012
Do you have a color image, or a gray scale image? Is it a color image but there are dark gray blobs in the color image? Well somehow you end up with a binary image. That could be using one of my color segmentation methods, or via k-means, but somehow, some way, you end up with a binary image that is like a "map" of where your dark gray pixels live. Then it depends on what you mean by make it red. You could take your color image and just modify the color channels in the regions of the binary image to be red, like
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Make it red where the binary image = true.
redChannel(binaryImage) = 255;
greenChannel(binaryImage) = 0;
blueChannel(binaryImage) = 0;
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
% Display it.
imshow(rgbImage);
Safaa
Safaa on 28 Sep 2012
Edited: Safaa on 28 Sep 2012
Sure! finally, and after applying this refinement step, I will end up with a binary image that have black regions representing the glands. I will check the solutions you have provided. Many thanks.

Sign in to comment.


julian tuyin
julian tuyin on 28 Oct 2016
hi, im having the same problem, what i did, was use the code from "cell image segmentation", on the image prosesing help, and once you get the image with the filled holes, and obviously the border image, you can do.
im=BWdfill-BWsdil
%image= image with filled holes - image with dilated borders.
you will get what you are looking for, you'll just have to adjust your borders. after that you can easily do, BWLABEL and REGIONPROPS.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!