Problem when changing labels in image
Ältere Kommentare anzeigen
Hello
I have a strange problem with labeling an image in MATLAB. I do not know if this is a problem occurring by my mistake or is caused by MATLAB.
I have a cell matrix with string names containing the classes (classification) of image objects called MK
The number of labels in the image is equal to Num
My label image is called LL
The problem occurring is that when I loop through the image and try to change the labels some of the objects within are lost. I do not know why this is happening. The labels within the image have a range from 1 to 8 (in this case) and the MK vector contains 8 class names.
My code look like this
for i=1:Num
ccc=MK(i);
% Convert to character
cc=char(ccc);
if strcmp(cc,'Water')
LL(LL==i)=100;
end
if strcmp(cc,'Soil')
LL(LL==i)=200;
end
if strcmp(cc,'Trees')
LL(LL==i)=300;
end
if strcmp(cc,'Vegetation')
LL(LL==i)=400;
end
if strcmp(cc,'Building')
LL(LL==i)=500;
end
if strcmp(cc,'Shadow')
LL(LL==i)=600;
end
end
I would really appreciate some help with this problem as I am stuck and I can not find a solution !
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 9 Jul. 2012
[tf, idx] = ismember( Mk, {'Water', 'Soil', 'Trees', 'Vegetation', 'Building', 'Shadow'} ); %and add the other two cases
LLsubset = (LL >= 1 & LL <= Num);
LL( LLsubset ) = idx( LL( LLsubset ) ) * 100;
3 Kommentare
Dimitris M
am 9 Jul. 2012
Walter Roberson
am 9 Jul. 2012
You have 8 classes in Mk but only test 6 of them ?
What do you observe when a label is "lost" ?
Dimitris M
am 13 Jul. 2012
Dimitris M
am 13 Jul. 2012
2 Kommentare
Image Analyst
am 14 Jul. 2012
At this point I think the only way we can make progress in helping you is for you to upload you LL file. Pick your favorite file hosting web site and let us know what the URL is. And tell us exactly how you create Mk.
Dimitris M
am 16 Jul. 2012
Kategorien
Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!