How do I find the percentage for the area of white colour over the area of the full image?
Afficher commentaires plus anciens
This is an image i have eroded and dilated. How do i find the percentage of the white ?

Réponse acceptée
Plus de réponses (2)
KSSV
le 10 Mai 2018
I = imread('ED.png') ; % REad the image
I = imcrop(I) ; % crop the required part
I = rgb2gray(I) ; % convert to gray image
whitepixels = nnz(I) ;
totalpixels = numel(I) ;
iwant = whitepixels/totalpixels
2 commentaires
John BG
le 10 Mai 2018
Hi KSSV
I just tried your code cropping the entire image and it returns
..
0 0 67
0 0 67
0 0 67
0 5 63
73 73 122
iwant =
0.155080657527910
does it look to you that the white thick dots are anywhere close to a 15% of the whole image?
KSSV
le 10 Mai 2018
Huummhh...sounds legitimate....what's the solution?
Nursyahirah Hafidz
le 11 Mai 2018
0 votes
2 commentaires
what do you mean by the percentage of your gui?
the percentage is already
amount_white_px/total_amount
use the amount directly, or x100.
Convert it to string with num2str() to use it in any command like: title xlabel ylabel or text, to add as comment directly on the screen?
Or has your gui a specific field? then plug the result to the gui field variable.
If you post another question asking how to key in this found percentage into your gui, and you attach your gui or a sample of it, I will show you how to use this result in your gui.
Regards
John BG
Image Analyst
le 11 Mai 2018
How do you want to display it? In a static text label? In a table control? Over the image in the text overlay?
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!