Effacer les filtres
Effacer les filtres

How can a greyscale image be labeled?

1 vue (au cours des 30 derniers jours)
Sheema Khattak
Sheema Khattak le 29 Avr 2014
Commenté : Sheema Khattak le 30 Avr 2014
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 commentaires
Image Analyst
Image Analyst le 29 Avr 2014
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 le 30 Avr 2014
I need to label the segmented portions of image for identification.No not small one

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Avr 2014
Modifié(e) : Walter Roberson le 29 Avr 2014
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.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by