フィルターのクリア

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

1 回表示 (過去 30 日間)
sumaiya khan
sumaiya khan 2018 年 12 月 12 日
回答済み: Image Analyst 2018 年 12 月 12 日
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);

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by