Help in image processing - how to count the number of black shapes on white image
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a fractography image. It consists of many black spots.. Black spots are of different shapes. I want to count the number of black spots...
Please find the attachment.
Please anyone suggest the code/command for this.. Any help is much appreciated..
2 comentarios
David K.
el 26 de Ag. de 2019
First you need to make this greyscale image fully black white. This can be done with a simple threshold with
threshold = 0.5; % fiddle with this
BW = im2bw(yourImage, threshold);
BW = ~BW; % the following code needs white spots black background
stats = regionprops('table',bw,'Centroid','MajorAxisLength','MinorAxisLength')
test if everything was found with
imshow(yourImage)
centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
hold on
viscircles(centers,radii);
hold off
Most likely, due to the complexity of your image you will need to look into adaptive thresholding as well as some image processing to clean it up such as imfill. Hope this gets you on your way.
UMANG NAGPAL
el 5 de Mayo de 2020
@David K
The above written has been done but How should I count the number of pores now?
I have got a plot , with circles covering the black regions/pores , but how should I count them?
Respuestas (1)
KALYAN ACHARJYA
el 26 de Ag. de 2019
Editada: KALYAN ACHARJYA
el 26 de Ag. de 2019
gray_image=imread('3.bmp');
% Improve the Thresholding to get more accurate answer
% Here I have used Global image threshold using Otsu's method
[T sm]=graythresh(gray_image);
bw_image=im2bw(gray_image,T);
[L hole_counts]=bwlabel(~bw_image);
fprintf('The Black holes counts: %d',hole_counts-1);
% 1 Minus for lower balck strips
2 comentarios
Ver también
Categorías
Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!