Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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.

Réponses (2)

KSSV
KSSV le 12 Déc 2018
A = nnz(binaryImage);
Or
A = sum(binaryImage(:));
  3 commentaires
KSSV
KSSV le 12 Déc 2018
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 le 12 Déc 2018
No, he needs divisions at 45 degrees, not rectangular quadrants.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 12 Déc 2018
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