Extracting data from a histogram

2 ビュー (過去 30 日間)
Kimo Kalip
Kimo Kalip 2018 年 6 月 29 日
コメント済み: Image Analyst 2018 年 7 月 4 日
Hello all, on the x-axis I have the gray levels, and on the y-axis I have the number of pixels, I think? I'm still trying to understand histograms, but I think what its telling me here is that there is a lot of dark pixels in my image, comparatively to histogram 2, which seems to have a lot less darker pixels. I want to make some sort of if statement, where: if there are around 200+ pixels of gray levels 50-60, then the image probably falls into category 1, else, it belongs in category 2. My roundabout solution to this problem is simply to create a threshold that only excepts pixels between 50-60 and then counting the number of objects (which would be 0 ideally in category 2's case), but this can't be the best way of accomplishing that. Any ideas would be appreciated!
  12 件のコメント
Kimo Kalip
Kimo Kalip 2018 年 7 月 3 日
編集済み: Image Analyst 2018 年 7 月 4 日
While I have the originals here, might I ask another separate question?
Is there any way to use the edge of the object to determine whether or not its shaped "properly"? (I says "properly" because the metric seems almost arbitrary, and I can't conceptualize how a computer is supposed to recognize abnormalities in a shape that is always different). I was thinking I'd take the slope of the edge, and that a steeper slope is more desirable, but the edge can also be shaped like ) or (, and it would still be "ok". However, a definite bulge like in image Two is something the computer is supposed to be able to recognize. Do you have any tips on where to start with a question like that?
Image Analyst
Image Analyst 2018 年 7 月 4 日
Sounds very ad hoc. Sure you can find the boundary and then take slopes perpendicular to the edge in a few places and see if the slopes are as expected. Or you can take the x-y path of the boundary curve and see if that is "straight enough" or "too bulged" whatever that means. Fit a section to a quadratic or whatever and look at the residuals of the actual to the fit. Pretty simple with polyfit() and polyval():
coefficients = polyfit(xActual, yActual, 2);
yFit = polyval(coefficients, xActual);
meanResidual = mean(abs(yFit-yActual))
or something like that. Basically you can do whatever you want - it just depends on how you define a "normal" looking curve.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2018 年 6 月 30 日
What KALYAN was saying is
binaryImage = grayImage <= 60;
if sum(binaryImage(:)) > 200
% It's the dark image type
else
% It's the lighter image type
end
However I like Adam's solution of simply comparing mean and standard deviation.
If either of these fail for some images, then we can try some more sophisticated image comparison methods like ssim() or image moments others.
  1 件のコメント
Kimo Kalip
Kimo Kalip 2018 年 7 月 3 日
編集済み: Kimo Kalip 2018 年 7 月 3 日
Ahh, this makes a lot of sense, thanks! I'll have to try it out before I do the accepted answer thing, but it seems like what I was going for - also clarified my original post in case anyone has any more input.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by