How can a greyscale image be labeled?

2 次查看(过去 30 天)
How can a greyscale image be labeled?
As bwlabel() works for labeling binary image how can we do the same for greyscale image in matlab
  2 个评论
Image Analyst
Image Analyst 2014-4-29
What's the use case? Why do you want this? What are you going to do with it? Can you give an example of the output you want for a small 7 by 7 image like this:
grayLevelImage =
1 1 2 4 5 5 1
5 4 1 3 2 1 5
3 2 1 3 2 1 4
5 1 1 3 3 1 4
2 3 4 1 4 1 1
3 1 2 3 3 4 5
4 1 3 5 2 3 5
Sheema Khattak
Sheema Khattak 2014-4-30
I need to label the segmented portions of image for identification.No not small one

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2014-4-29
编辑:Walter Roberson 2014-4-29
labelled_image = zeros(size(YourImage),'uint16');
label_hw = 0;
max_grey = max(YourImage(:));
for K = 1 : max_grey
T = bwlabel(YourImage == K);
numlabel_here = max(T(:));
for L = 1 : numlabel_here
labelled_image(T == L) = label_hw + L;
end
label_hw = label_hw + numlabel_here;
end
At the end of this, labelled_image will be labelled such that each connected area that is all a single greyscale level will be considered to be a single class.
This is unlikely to be what you want: you probably want that "nearby" greyscale levels are merged together but that "edges" are recognized. That kind of separation is what segmenting is for.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by