black dots marked in that red boundary is to be counted
How to count no of black spots in a image??
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clc
A5=imread('C:\Users\AMIT\Desktop\CB\sulphur\4-1.jpg');
imshow(A5);
background = imopen(A5,strel('disk',15));
I2 = A5- background;
figure, imshow(I2)
I3 = imadjust(I2);
figure, imshow(I3);
level = graythresh(I3); %Threshold the Image
bw = im2bw(I3,level);
C = imcrop(bw);
bw2 = bwareaopen(C,2);
figure, imshow(bw2)
cc = bwconncomp(bw2,8) %Identify Objects in the Image
P=cc.NumObjects;
SP=0.64/4;
defectdata = regionprops(cc, 'basic') %Compute Area of Each Object
DA = SP*[defectdata.Area];
[min_area, idx] = min(DA) %Compute Area-based Statistics
[max_area, idx] = max(DA)
nbins = 20; %Create Histogram of the Area
figure, hist(DA,nbins)
title('Histogram of defect Area');
xlabel('Area of defect mm2');
ylabel('Number of defects')
Ylim ([0 50])
DA
4 commentaires
Réponses (1)
Image Analyst
le 23 Juin 2021
You already compute it, in your "P" variable. You probably just didn't notice because of the poor choice of some of your variable names that are not descriptive at all.
See my Image Segmentation Tutorial:
You might need to define just how small of a spot do you want to find.
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!