Azzera filtri
Azzera filtri

How can a greyscale image be labeled?

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Image Analyst
Image Analyst il 29 Apr 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 il 30 Apr 2014
I need to label the segmented portions of image for identification.No not small one

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 29 Apr 2014
Modificato: Walter Roberson il 29 Apr 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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by