필터 지우기
필터 지우기

Finding the area of multiple segments and circles

조회 수: 6 (최근 30일)
A K
A K 2017년 7월 28일
댓글: Image Analyst 2017년 7월 31일
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
Image Analyst
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.
A K
A K 2017년 7월 30일
편집: A K 2017년 7월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
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
A K
A K 2017년 7월 31일
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 2017년 7월 31일
mask = poly2mask(xPizza, yPizza, rows, columns);
areaFraction = sum(binaryImage(mask)) / sum(mask(:))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by