Identifying the circle that fits the outer white pixels in a binary image (or make external mask)

B
Bouhadjra · Feb 15, 2022 · 2K views
Question
Hi all,   I want to process a series of images similar to the attached one in order to measure their porosities: V_pores / V_total. For my case, in a 2D context, V_total is the surface of circle containing all pores. It is important to know that the radius and center of the circle changes, and also many circular shapes can be identified in between, however, I am only interested, at this moment, in measuring the general surface of the circle (Vt).   Alernatively, I would be interested in applying a mask to the image. But it seems to be more difficult.
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Nov 20, 2025
I = imread("SampleXRmorph.PNG");
[y,x] = find(I) ; 
% Get center of cricle 
C = [mean(x) mean(y)] ; 
% GEt raidus 
d = sqrt((C(1)-x).^2+(C(2)-y).^2) ; 
R = max(d) ;  
% plot circle 
th = linspace(0,2*pi) ; 
xc = C(1)+R*cos(th) ; 
yc = C(2)+R*sin(th) ; 
% 
imshow(I)
hold on
plot(xc,yc,'r')

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!