MATLAB Answers

Looking for the ways to categorize the black dots by the number of pixels...

4 views (last 30 days)
Dongwon Kim
Dongwon Kim on 31 Jul 2019
Commented: Dongwon Kim on 31 Jul 2019
1bij.jpg
Hello, I have another question from the image processing. This is the X-ray Diffraction image of metal sample and black dots are pores.
Yesterday, I successfully found the ratio of black and white pixel area in the circular area.
[rows colm]=size(BW);
white_pixels=sum(BW(:));
black_pixels=~BW;
black_pixels=sum(black_pixels(:));
result=bwareafilt(~BW,1,'Largest');
outer_black=sum(result(:));
% Area with respect to circle only
black_pixels_area=(black_pixels-outer_black)/((rows*colm)-outer_black);
fprintf('The Percentage of black pixels covered area is %.2f ',black_pixels_area);
fprintf('\n The ratio black/white is %.2f',black_pixels/white_pixels);
This was the code made by KALYAN ACHARJYA. (I really appreciate his help)
Now my senior wants me to find out the ways to categorize the pores by the number of dots in the picture. For example,
-number of pores with only one pixel = n1
-number of pores with two pixels = n2
-number of pores with three pixels = n3
and so on...
I guess I have to find out the ways to calculate the number of pixels for each pores, there are many qna about the total number of pixels in the area but could hardly find the ways to calculate the pixel number for each feature...
I would really appreciate your assistance.

  0 Comments

Sign in to comment.

Accepted Answer

Akira Agata
Akira Agata on 31 Jul 2019
I strongly believe the regionprops function will be your help. The following is an example:
% Read image and binarize
I = imread('1bij.jpeg');
Igray = rgb2gray(I);
BW = imbinarize(Igray);
% Apply regionprops function
s = regionprops('table',~BW);
% Count number of pores (for size <= 10 pixel)
idx = s.Area <= 10;
figure
histogram(s.Area(idx))
xlabel('# of pixels per pore','FontSize',14)
ylabel('Number of pore','FontSize',14)
pore.png

More Answers (0)

Sign in to answer this question.