Labeling objects in grayscale image in matlab
13 views (last 30 days)
Show older comments
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
1 Comment
Image Analyst
on 27 Sep 2012
To upload your image, use tinypic.com, or some other site here: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Answers (3)
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
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');
See my image segmentation tutorial for a full demo: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Or you can see this: http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html
3 Comments
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);
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.
0 Comments
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!