필터 지우기
필터 지우기

How can i calculate the area of white pixels in each quadrant and display it individually.

조회 수: 1 (최근 30일)
Using the centroid, a binary image is divided into four quadrants at an angle of 45 degree. I need to calculate the area of white pixels in each quadrant. How can i calculate the area of white pixels in each quadrant and display it individually.

답변 (2개)

KSSV
KSSV 2018년 12월 12일
A = nnz(binaryImage);
Or
A = sum(binaryImage(:));
  댓글 수: 3
KSSV
KSSV 2018년 12월 12일
YOu can use imcrop four times for the parts you want. Or use:
I1=I(1:size(I,1)/2,1:size(I,2)/2,:);
I2=I(size(I,1)/2+1:size(I,1),1:size(I,2)/2,:);
I3=I(1:size(I,1)/2,size(I,2)/2+1:size(I,2),:);
I4=I(size(I,1)/2+1:size(I,1),size(I,2)/2+1:size(I,2),:);
Image Analyst
Image Analyst 2018년 12월 12일
No, he needs divisions at 45 degrees, not rectangular quadrants.

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


Image Analyst
Image Analyst 2018년 12월 12일
Construct triangles, like 3 or 4 points defining the vertices (2 along the edge and one at the center). Then use poly2mask(). Untested code follows:
[rows, columns, numColors] = size(binaryImage);
xCenter = columns/2;
yCenter = rows / 2;
x = [1, columns, xCenter, 1]; % Top triangle
y = [1, 1, yCenter, 1];
hold on;
plot(x, y);
mask = poly2mask(x, y, rows, columns);
pixelsInMask = binaryImage(mask); % a 1-2 vector of pixels in the triangle.
numWhitePixelsInMask = nnz(pixelsInMask);

Community Treasure Hunt

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

Start Hunting!

Translated by