Finding a local minimum in a histogram

8 views (last 30 days)
Jonathan Cheng
Jonathan Cheng on 19 Aug 2016
Answered: Image Analyst on 20 Aug 2016
I would like to search for the first local minimum in a histogram and determine a threshold value from that. The histogram represents the distribution of intensities of a image-based DNA sequencing experiment, from a total of n=742. Basically, I expect a bimodal distribution of "background" of low intensities and "signal" of high intensities. From the attached image, one can see an obvious left peak of background intensities. I hope to find the intensity at the bottom of the first trough. I have seen a few ways of doing this, including using histcounts but that was not robust to noise in the histogram and bin sizing. I am wondering if someone can recommend an algorithm that will be robust to noise and to bin sizing (i.e. not just using an arbitrary bin size). Thanks.

Answers (2)

Star Strider
Star Strider on 19 Aug 2016
I can’t tell if the first minimum is the absolute minimum, or something else. If you have the Signal Processing Toolbox, I would take the negative of the counts in your histogram, and use the findpeaks function on it. See the documentation on findpeaks for details.

Image Analyst
Image Analyst on 20 Aug 2016
If you want a robust way of finding the "corner" on the right side of the histogram that is robust to noise, you can try findpeaks() but you might have to fiddle around with a dizzying array of options to determine what is a 'true" peak and what's just a noise blip on the side of a larger peak.
OR you could try the triangle thresholding method. I've attached it. Basically you give it the counts array and tell it what side you want it to find the "corner" of. Essentially it draws a hypoteneusa line from the far tail to the peak. Then it sends lines in perpendicularly in from that line to the actual counts array and finds the gray level which has the longest line. This is the line which will go from the hypoteneuse into the farthest "corner" of the counts array. Essentially it finds the bottom of the hump.

Community Treasure Hunt

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

Start Hunting!