Image Analysis with flow and gray scale
Mostra commenti meno recenti
Hello. I am trying to calculate the percentage of the white foam for this image. I am struggling because I can either do a 8 bit binary black and white but it takes out some of the foam that is less dense and not completely white. The color of the foam varies. The second way I approached it was using a RBG analysis. I basically just analyzed the closest ranges for gray to white and black as the background.
Do any of you know how to separate the foam from the background more accurately?
Thanks
I = imread('test5.png') ;
figure;
imshow(I)
BW = im2bw(I,0.4);
figure; imshow(BW)
percentageBlack=(1-nnz(BW)/numel(BW))*100
%%%%another method
clear all
clc
filename = 'test5.png';
RGB = imread(filename);
grayscale = rgb2gray(RGB);
numTotalPixel = size(grayscale,1) * size(grayscale, 2);
numBlackPixel = sum(grayscale(:)<= 80);
numWhitePixel = sum(grayscale(:)>140);
numGrayPixel = sum(grayscale(:)>80)-numWhitePixel;
percentBlackPixel = numBlackPixel / numTotalPixel * 100
percentWhitePixel = numWhitePixel / numTotalPixel * 100
percentGrayPixel = numGrayPixel / numTotalPixel *100
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image Processing and Computer Vision in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!