The last week I spent some time on histograms and object recognition using histograms. Histograms are a collection of bins for counting pixels with certain characteristic. Histograms can have multiple dimensions: each bins can be described by more than one variable.
I worked with 2D histogram: hue (the tint) and saturation (the amount of grey) as dimensions. These histograms are used for basic face detection. In order to recognize an object, using histograms, a precise and noiseless object histogram is slided over the scene to find the area where the match is highest.
On the left the object to search (I used the red background because is easier to isolate in the histogram). On the right the histogram: the horizontal direction represents hue, the vertical saturation.
The test scene (key is visibly on the center).
The back-projection: the matching map against the object histogram (the brighter the pixels the higher the matching). A black square highlights the area were the brightest pixels are, for a more precise detection we should look for an area as wide as the key and use the average rather than the maxima.