Size filtering and show the position of centroids on the image
Ältere Kommentare anzeigen
I have a binary image, BW and a grayscale image, I. I want to select only regions in the binary image with the same value that have an area > 50. For example there are 70 regions with area>50 and BW==1. I wonder how to show the position of the centroids of these regions with their number (1:70) on the image. Any suggestions?
Akzeptierte Antwort
Weitere Antworten (3)
bym
am 17 Dez. 2011
from the documentation:
I = imread('coins.png');
figure, imshow(I)
bw = im2bw(I, graythresh(getimage));
figure, imshow(bw)
bw2 = imfill(bw,'holes');
L = bwlabel(bw2);
s = regionprops(L, 'centroid');
centroids = cat(1, s.Centroid);
%Display original image and superimpose centroids.
imshow(I)
hold(imgca,'on')
plot(imgca,centroids(:,1), centroids(:,2), 'r*')
hold(imgca,'off')
3 Kommentare
Hassan
am 18 Dez. 2011
Image Analyst
am 18 Dez. 2011
Obviously then you didn't look up my BlobsDemo. Any reason why not?
Hassan
am 19 Dez. 2011
Walter Roberson
am 18 Dez. 2011
If centroid #K is at position x, y, then to label that point on the graph with that number, use
text(x,y,num2str(K));
1 Kommentar
Hassan
am 19 Dez. 2011
Devie Nur AIni
am 20 Dez. 2021
Bearbeitet: Image Analyst
am 20 Dez. 2021
Ada yang tau ga kenapa pas coba aku running dia eror dan tulisannya
"check for missing argument or incorrect argument data tupe in call to function 'centroid'
% Peroleh pusat massa dan letakkan di tengah citra
[xc, yc] = centroid(m,n);
xc = round(xc);
yc = round(yc);
xc = xc - round((n/2));
yc = yc - round((m/2));
1 Kommentar
Image Analyst
am 20 Dez. 2021
@Devie Nur AIni, you have evidently, according to the error message, created a function called centroid, and that function does not expect two inputs m and n. Place your cursor in there and type control-D to edit that function. Or else do this on the command line:
>> edit centroid.m
I don't know what that function is supposed to do. Did you write it, or did someone else write it and you just put it on your computer?
Kategorien
Mehr zu Image Arithmetic 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!
