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

Illustration
Bouhadjra - 2022-02-15T10:14:27+00:00
Question: Identifying the circle that fits the outer white pixels in a binary image (or make external mask)

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 answered . 2025-11-20

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')

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!