Extracting data from a histogram
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
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.
Réponse acceptée
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!