Image Analysis with flow and gray scale

2 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2017-2-22
I have done foam/suds/lather analysis. If a gray level (like 100) might be foam in one location, but background in another location, then you're going to have to come up with some descriptor of foam that depends on more than simply the gray scale. I don't know what that might be. Maybe you need to do some spatial processing first, like using adapthisteq() or something.
  4 个评论
Christine Nee
Christine Nee 2017-2-22
Then you would go back and do a pixel analysis on it?
Image Analyst
Image Analyst 2017-2-22
I filled in the clear bubbles using imclose(). Then I thresholded, smoothed the boundaries a bit I think, and finally got area fractions from the histogram.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by