use of "if" and "elseif" in regionprops
Mostra commenti meno recenti
I want you establish a range scale for the outputs on images for example if my value is coming between
value >= 7.94 & value <= 11.11 ==============> this should display "#3" on the image.
I have tried to develop a script with 'if" and "elseif" but I am unable to make it work.
Follwoing is the code I am using
L1 = bwlabel(barsH);
k=regionprops(L1,'Area','Perimeter','Centroid');
score= (([k.Area])./([k.Perimeter]/1.5));
figure, imshow(barsH);
morespace=60;
for cnt = 1:length(k)
if score >= 7.94 & score <= 11.11
score = "#3";
text(k(cnt).Centroid(1),k(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" mm",'FontSize',12,'color','red');
elseif score >= 11.12 & score <= 14.28
score = "#4";
text(k(cnt).Centroid(1),k(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" mm",'FontSize',12,'color','red');
elseif score >= 14.29 & score <= 17.45
score = "#5";
text(k(cnt).Centroid(1),k(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" mm",'FontSize',12,'color','red');
end
end
File "barsH.mat" is enclosed.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image Arithmetic 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!
