I am doing template maching using Normalized Cross-Correlation for measuring similarity between template and image.

However, some images from my dataset contain saturated pixels (overshoot) which should be avoided in the measurement.

How to update the cross-correlation computation to avoid saturated pixels?

enter image description here

  • $\begingroup$ Would setting the saturated pixel values to zero work? $\endgroup$ – AnonSubmitter85 Sep 17 '14 at 21:11

I have finally found an aswer in a technical report "Image Alignment and Stitching: A Tutorial" from Richard Szeliski.

A weighted SSD (Sum of Suqared Differences) function is presented on page 13:


where $w_{0},w_{1}$ are spatially-varying weight functions (for template and the image). $u$ is a template offset.

The result may be divided by the overlap area to avoid bias towards smaller overlap.

This however works for SSD metric, not NCC. But it may suffice once images are normalized beforehand (using contrast/brightness adjustment computed using linear regression over corresponding pixel intensities).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.