Extracting data from a histogram
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kimo Kalip
el 29 de Jun. de 2018
Comentada: Image Analyst
el 4 de Jul. de 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 comentarios
Image Analyst
el 4 de Jul. de 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.
Respuesta aceptada
Image Analyst
el 30 de Jun. de 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 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!