Finding the area of multiple segments and circles

10 visualizzazioni (ultimi 30 giorni)
Hi!
I have a set of two data derived from an image, I was able to extract particle coordinates using the hough transform and then focus on a specific region of particles in an image.
I've been struggling to compute the area of the circles lying on the boundary of the segment in the figure plot below. I have tried using patch and fill to check if my techniques would work but for some reason they don't.
I am interested in calculating the area packing fraction of the circles highlighted in red, including the fraction of a circle that is cut into the segment of interest.
I have managed to create the following plot:
So far I have been very close and managed to generate this plot:
Using the inpolygon function and some further alteration I get this image:
Any ideas?
After some alteration I manage to acquire the following figure in which discs not touching the segment boundary are excluded:
The packing fraction of interest is the area of the all the circles and segments in red divided by the area of the blue pizza slice minus the area of the large red circle within the blue slice.
r = 600; center_inner = [654, -23]; radius_inner = 125; theta=deg2rad(30);
for i = 1:length(coords.radii);
circle_fraction(i,:) = nnz(in(i,:))/min(size(in));
end
Areaa_Circles = pi*coords.radii.^2;
Area_Circles = pi*coords.radii.^2.*circle_fraction;
Area_Wedge = 0.5*theta*r^2 -0.5*theta*radius_inner^2;
packing_fraction = nansum(Area_Circles)/Area_Wedge
particlesx = particlesx.*in;
particlesy = particlesy.*in;
coords.particlesx(circle_fraction < 1) = nan;
coords.particlesy(circle_fraction < 1) = nan;
figure;
hold on
plot(particlesx,particlesy,'k.');
plot(coords.wedgex,coords.wedgey);
viscircles([center_inner(1) center_inner(2)],radius_inner);
hold off
set(gca,'Ydir','reverse')
My Problem is that the function keeps returning a packing fraction > 1, and i believe i'm doing something wrong in my approach to determining the areas of the segmented circles at the boundary of the wedge.
Any advice would be appreciated, thanks!
  2 Commenti
Image Analyst
Image Analyst il 28 Lug 2017
Any ideas on what? I don't even know what this means: "I've been struggling the area of the 'cut-off' circles." How do you struggle an area?
Just say what you want to do. And attach the original image and code if you think that will help people to help you.
A K
A K il 30 Lug 2017
Modificato: A K il 30 Lug 2017
Hi Image Analyst, please do let me know if my above edits have provided clarification! From the second image you can see certain circles are cut off by the segment of interest (pizza slice minus the larger circle) leaving us with circular segments at the boundary.
I had tried computing the area of those circles by using inpolygon, and multiplying the area of the original circle by the fraction of points within the segment, but this has not worked.

Accedi per commentare.

Risposta accettata

John D'Errico
John D'Errico il 30 Lug 2017
Modificato: John D'Errico il 30 Lug 2017
To me, this seems easy enough.
1. Find each circle in the ENTIRE image, not only in the wedge shaped region. Make sure you find only circular regions that are within a specific size range. This caters to avoiding spurious small vaguely circular holes.
2. Fill each circle with the same color as the perimeter of the circles.
3. Essentially do a polygonal crop, turning everything outside of the wedge to white.
4. Count the number of red pixels that remain. The ratio of the red pixel count to the total number of pixels inside the wedge gives you the area inside the circles.
I lack the IPT, so I cannot give you code. But each step above should be pretty simple.
One issue might be in terms of the edge width of the circles, thus possibly overestimating the area contained.
However, if you know the line thickness for the perimeter, AND you know the diameter of the circles you have found, you can then try to make a simple first order correction for that line thickness, IF it is perceived to be a problem.
  2 Commenti
A K
A K il 31 Lug 2017
I could not figure out how to eliminate via polygonal crop, but i managed to 'solve' (not sure if im right) by generating these three images, since this question has been viewed a fair amount I will brush up the code and add it in the question.
Image Analyst
Image Analyst il 31 Lug 2017
mask = poly2mask(xPizza, yPizza, rows, columns);
areaFraction = sum(binaryImage(mask)) / sum(mask(:))

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by