Problem when changing labels in image
Mostra commenti meno recenti
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 !
Risposta accettata
Più risposte (2)
Walter Roberson
il 9 Lug 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 Commenti
Dimitris M
il 9 Lug 2012
Walter Roberson
il 9 Lug 2012
You have 8 classes in Mk but only test 6 of them ?
What do you observe when a label is "lost" ?
Dimitris M
il 13 Lug 2012
Dimitris M
il 13 Lug 2012
2 Commenti
Image Analyst
il 14 Lug 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
il 16 Lug 2012
Categorie
Scopri di più su Entering Commands in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!