Reputation: 3289
I am working on an object tracking problem. I have two histograms of an object in
a consecutive frames. Lets say these histograms are computed at time instances t-1
and t
. Below is an example of these two histograms.
As can be seen from the first histogram (computed at time instant t-1
), all the peaks/distributions of the histogram are concentrated near to intensity value 100. This basically represents an object. However, at time instant t
, there appears some unnecessary peaks (around intensity value 75).
I want to remove these peaks from the second histogram, therefore, would like to ask if there exists some robust method to do this job. These unnecessary peaks exist in almost every frame, therefore, by using some simple thresholding would not help me.
What I am currently doing (Threshold method): I compute median and standard deviation from the histogram att-1
and threshold current histogram at t
, by using a following formula:
low_thresh = med(t-1) - alpha*std(t-1)
high_thresh = med(t-1) + alpha*std(t-1)
hist_without_unnecessary_peaks = low_thresh < current_hist(t) < high_thresh
This alpha
is a parameter which can be adjusted. This way, I propagate this thresholding throughout all the frames. But, I don't get the robust result. Would be glad if somebody can please help me. Thanks.
Upvotes: 2
Views: 1375
Reputation: 281
Sanchit, I had to solve this issue when I was handling with RGBD cameras as well.
The solution:
(A) Apply the following contrast function on your histogram:
where C(i,n) is the new histogram at index i
(of the old histogram) and n
is a parameter that you choose (and tune) - Note that this results in a new histogram, n is just a parameter
(B) Find all local maxima/minima points on your histogram and choose the maximal one. There is plenty of maxima/minima finding Matlab code on the web so you will not have a problem.
Hope it helps.
Upvotes: 1
Reputation: 3547
Can you use a larger number of consecutive frames? If so, and the peaks that you wish to keep are consistent enough (which looks like they are) then you can take the median values across multiple frames.
So instead of computing the median for the entire histogram, do it for each individual intensity value with the previous frame and the next frame (or with more frames for more accuracy). Then use the median value as the new intensity value in the histogram. This will remove the outliers (i.e. the noise you're seeing in the second frame).
Upvotes: 1