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

24 ビュー (過去 30 日間)
ruban ramalingam
ruban ramalingam 2019 年 8 月 26 日
コメント済み: UMANG NAGPAL 2020 年 5 月 5 日
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
  2 件のコメント
ruban ramalingam
ruban ramalingam 2019 年 8 月 26 日
Thank you sir.. I want to measure the sizes of various holes and I want to plot the histogram of various pore sizes..
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 26 日
See regionprops

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by