finding number of pixels inside each circle
조회 수: 15 (최근 30일)
이전 댓글 표시
i am drawing circles of different radius on a jpg image. how to find the number of pixels in each circle. i have to compare the pixel distribution ratio in each circle
댓글 수: 3
채택된 답변
Image Analyst
2015년 1월 26일
I'm pretty sure I gave you the answer in your other question: http://www.mathworks.com/matlabcentral/answers/169093#comment_261946 How is this any different than that?
댓글 수: 3
Image Analyst
2015년 1월 26일
Just try it and see. Create a mask for triangles with poly2mask().
xTriangle = [x1,x2,x3,x1]; % Make a list of the coordinates of the vertices.
yTriangle = [y1,y2,y3,y1];
[rows, columns, numberOfColorChannels] = size(yourImage);
binaryImage = poly2mask(xTriangle, yTriangle, rows, columns);
추가 답변 (1개)
Thorsten
2015년 1월 21일
A well-known "approximation" is :-)
N = round(radius^2*pi)
You could also create a circle and count the pixels:
radius = 100;
x = [-radius: radius];
[X, Y] = meshgrid(x, x);
R = sqrt(X.^2 + Y.^2);
N = numel(find(R<=radius));
Both values are almost the same.
댓글 수: 2
Thorsten
2015년 1월 26일
You can just use any other value for the radius, like
radius = 50;
and then compute the N to count the pixels in the circle of radius 50. Or what else do you need?
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!