Extracting data from a histogram

2 vues (au cours des 30 derniers jours)
Kimo Kalip
Kimo Kalip le 29 Juin 2018
Commenté : Image Analyst le 4 Juil 2018
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 commentaires
Kimo Kalip
Kimo Kalip le 3 Juil 2018
Modifié(e) : Image Analyst le 4 Juil 2018
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 le 4 Juil 2018
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.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 30 Juin 2018
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 commentaire
Kimo Kalip
Kimo Kalip le 3 Juil 2018
Modifié(e) : Kimo Kalip le 3 Juil 2018
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by