calculate the percentage of B&W image

17 visualizzazioni (ultimi 30 giorni)
titi sari
titi sari il 28 Giu 2018
Modificato: Guillaume il 29 Giu 2018
I have a black and white image, how do I calculate the percentage of the white area over the black area?

Risposte (2)

Guillaume
Guillaume il 29 Giu 2018
Modificato: Guillaume il 29 Giu 2018
percentageWhite = nnz(yourimage) / numel(yourimage);
nnz gives you the number of white pixels, numel the total number of pixels.
And note:
percentageBlack = nnz(~yourimage) / numel(yourimage);

Nithin Banka
Nithin Banka il 29 Giu 2018
If 'BW' is your binary threshold image,
pix = size(BW);
no_of_pix = pix(1)*pix(2);
no_of_white_pix = sum(sum(BW==1));
percent_of_white_pix = no_of_white_pix*100/no_of_pix; %This gives the percentage of white in the image.

Categorie

Scopri di più su Denoising and Compression in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by