How to find percentage of white pixels in a binary image?

14 ビュー (過去 30 日間)
Miraj Khalid
Miraj Khalid 2021 年 6 月 14 日
回答済み: Simon Allosserie 2021 年 6 月 14 日
I took this image and converted it to binary image. then i filtered the image to remove the noise. after that i applied the dilate and erode process to make it more clear, afterthat i want to find the %age of white pixels which are actually the micro-cracks in a solar panel. i have used the code but I'm not getting any result. kindly take a look on the .m file to understand better.
any help will be apprecited.
thanks in advance.

採用された回答

Simon Allosserie
Simon Allosserie 2021 年 6 月 14 日
Hi
You could simply use nnz(A), which gives the number of non-zero elements in the matrix A, and numel(A), which gives the total number of elements in A. As white is '1' and black is '0' in your binary image, using nnz(A)/numel(A) gives you the percentage of white pixels.
See https://nl.mathworks.com/help/matlab/ref/nnz.html and https://nl.mathworks.com/help/matlab/ref/double.numel.html

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by