Finding the area of multiple segments and circles
2 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166400/image.jpeg)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166401/image.jpeg)
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 个评论
Image Analyst
2017-7-28
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.
采纳的回答
John D'Errico
2017-7-30
编辑:John D'Errico
2017-7-30
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 个评论
Image Analyst
2017-7-31
mask = poly2mask(xPizza, yPizza, rows, columns);
areaFraction = sum(binaryImage(mask)) / sum(mask(:))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!