views:

836

answers:

1

I would like to track a color in a set of images. For this reason I use the algorithm of constant thresholding mentioned in Introduction to Autonomous Mobile Robots. This method simply marks all those pixels that are among a minimum and a maximum threshold of red, green, blue (or hue, saturation, value in my case).

My problem is that - although HSV is less sensitive to changing light conditions - I still would like to set the thresholds from program to minimize the number of false positives and false negatives. In other words the algorithm would ensure that only a given set of pixels is marked in the end, for example a rectangle on a calibration image.

I know that the problem is a search in a 6-dimensional parameter space and I could come up with possible solutions but I am looking for other programmers' opinion and experience on this subject.

If that matters I try to implement it in C++ with OpenCV.

+1  A: 

As far as I understand the question you are looking for procedure to calibrate 6 thresholds (min and max for each of the HSV channels) from a calibration image that contains your tracking marker. To achieve this I would:

  1. first manually delineate the region, in the calibration image, where the marker appears
  2. calculate that region's histograms, one for each of the HSV channels
  3. set the min and max thresholds to the histogram percentiles 0.05 and 0.95 respectively

Not using the histogram's minimum and maximum values, but rather its 0.05 and 0.95 percentiles helps the measure be more robust to noise.

EDIT:

A modification of the second step: If you want to minimize the error, you could establish a normilzed histogram of the marker and a normalized histogram of the environment (this can be 2 separate images) and subtract the latter from the first. The resulting marker histogram will have background pixel values attenuated. This will affect the values of the above mentioned percentiles.

Ivan
Interesting solution without the need of the search. My problem is that it does not ensure that only a minimal number of marked pixels will appear outside the delineated region. Moreover I do not want manual step in the process.
rics
If you want to avoid a manual step, you can display the marker so that it appears full screen. Regarding the point that you want to ensure a minimal number of errors, you should understand the limitations of threshold based object detection, and that it is not robust to changes in acquisition modalities, ambient light, etc. Usually people use thresholding + some form of filtering.
Ivan