Image Analysis with flow and gray scale

조회 수: 7 (최근 30일)
Christine Nee
Christine Nee 2017년 2월 21일
댓글: Image Analyst 2017년 2월 22일
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개)

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by