Histogram peak identification and gauss fitting with minimal accumulated hight difference in c++
I already asked a similar question some time ago in the following thread: previous thread. Until now I unfortunately couldn't entirely solve that issue and only worked around. Since it is difficult to include all the new information with the previous thread I post a refined and extended question with distinct context here and link it to the old thread.
I am currently implementing an algorithm from a paper which extracts certain regions of a 3D data set by dynamically identifying value ranges in the data sets histogram. In a simplified way the method could be described as following:
- Find the highest peak in the histogram
- Fit a gaussian to the peak
- Using the value range defined by the gaussians mean (µ)+/- deviation(ϭ) certain regions of the histogram are identified, and the voxels (=3D pixels) of these regions are removed from the original histogram.
- As a result of the previous step a new highest peak should be revealed, based on which the steps 1-3 can be repeated. The steps are repeated until the data set histogram is empty.
My questions relate to step 1 and 2 of the above description which is described as following in the paper: "The highest peak is identified and a Gaussian curve is fitted to its shape. The Gaussian is described by its midpoint µ, height h and deviation ϭ. The fitting process minimizes the accumulated height difference between the histogram and the middle part of the Gaussian. The error summation range is µ+/ϭ? "1
In the following I will ask my questions and add my reflections on them:
- How should I identify those bins of the total histogram which describe the highest peak? In order to identify its apex I simply run through the histogram and store the index of the bin with the highest frequency. But how far should the extend of the peak reach to the left and right of the highest bin. At the moment I simply go the the left and right of the highest bin for as long as the next bin is smaller as the previous one. However this is usually a very small range, since there occur creases (mini peaks) in the histogram. I already thought about smoothing the histogram. But I would have to that after each iteration since the subtraction of voxels (step 3 in the description above) can cause the histogram to contain creases again. And I am also worried that the repeated smoothing distorts the results. Therefore I would like to ask whether there is an efficient way to detect the extend of a peak which is better than my current approach. There have been suggestions about mixture models and deconvolution in the previous thread. However are these methods really reasonable if the shape of the histogram constantly changes after each iteration?
- How can I fit a gauss curve to the identified peak so that the accumulated hight difference between the histogram and middle part of the ga开发者_如何转开发ussian is minimized? According to question one from the previous thread I fitted the curve to a given range of histogram bins by computing their mean and deviation (I hope this is correct?!). But how do I minimize the accumulated hight difference between the histogram and middle part of the gaussian from this point?
Thank you for your help! Regards Marc
Add histogram values to the left and right until the goodness of the fit begins to decrease.
精彩评论