Check if the code is correct or not for finding the diameter of objects in an image.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sir here I attached the code for finding the diameter of irregularly shaped objects in an image. Tell me if the code is correct to find the diameter or not .
if true
% code
end
originalImage = imread('result.jpg');
originalImage=rgb2gray(originalImage);
labeledImage = bwlabel(originalImage, 8);
D=regionprops(labeledImage,'area');
d1=regionprops(labeledImage,'EquivDiameter');
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 9 Okt. 2012
No, you need to create a binary image first, plus you can do it all in one call to regionprops():
originalImage = imread('result.jpg');
originalImage=rgb2gray(originalImage);
binaryImage = originalImage > thresholdValue; % for example 80 or 142 or some value.
labeledImage = bwlabel(binaryImage, 8);
D=regionprops(labeledImage,'area','EquivDiameter');
5 Kommentare
Image Analyst
am 10 Okt. 2012
You'd have to multiply the value from graythresh by 255 because that gives you a value in the range 0-1. Other than that it looks fine but you'd have to decide if graythresh's method (the "Otsu" method) works in your situation. I find that often it doesn't pick the best threshold and so I have to custom write a method to pick the threshold.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Display Image finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!