Extracting data from a histogram
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kimo Kalip
am 29 Jun. 2018
Kommentiert: Image Analyst
am 4 Jul. 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 Kommentare
Image Analyst
am 4 Jul. 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.
Akzeptierte Antwort
Image Analyst
am 30 Jun. 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 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!