Help in image processing - how to count the number of black shapes on white image

3 次查看(过去 30 天)
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 个评论
David K.
David K. 2019-8-26
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
Then you can use regionprops to identify every spot
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
UMANG NAGPAL 2020-5-5
@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?

请先登录,再进行评论。

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-8-26
编辑:KALYAN ACHARJYA 2019-8-26
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

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by