Fondazione Bruno Kessler - Technologies of Vision

contains material from
Template Matching Techniques in Computer Vision: Theory and Practice
Roberto Brunelli © 2009 John Wiley & Sons, Ltd

5.3 Bhat-Nayar correlation

A simple and useful way to characterize the discriminatory power of a template matcher is to compute its signal to noise ratio SNR: its response at the correct location divided by its average response everywhere else. If the SNR is high, detection is expected to be reliable. We can detect our template simply by thresholding the response of the detector: small amounts of noise are not expected to make the value drop below threshold or making the value of other patterns arise above threshold. If the SNR is low, detection by thresholding might be unreliable or downright impossible. Function tm.snr provides a sample implementation of this quality parameter:

1 tm.snr <- function(map, at) { 
2 ...   n <- ia.size(map) 
3 ...   map[at[2], at[1]]/((sum(map@data) - map[at[2], at[1]])/(n-1)) 
4 ... }

We can apply the concept of SNR to the comparison of the original Bhat-Nayar correlation measure (Equation TM:5.24) to the modified version Equation TM:5.27. The testbed we consider is that of matching a no-noise version of the eye region of the original face face image to a noisy version of the dark face. We compute the modified Bhat-Nayar correlation weighting the average part of the contribution with α:

            [           N   i     ∑N     i]
rB′N (α) = 1-  (1 - α)max-i=1dm- + α--i=12d-m  .
                       ⌊N2 ⌋        ⌊N4 ⌋
(5.1)

When α = 0 we recover the original Bhat-Nayar definition, while α = 1 keeps only the average distance. In order to compute the SNR we must identify the reference template position: the image coordinates representing the upper left corner of the eye template, i.e. (38,89). Besides computing the signal to noise ratio, we want to check the actual correlation value returned at the reference template location.

1 nDark  <- tm.addNoise(dark, "saltpepper", scale=255, clipRange=c(0L, 255L), 
2 ...                       percent = 0.01) 
3 alphas <- seq(0,1,0.1) 
4 n      <- length(alphas) 
5 snrs   <- array(0, dim = c(n, 3)) 
6 for(a in 1:n) { 
7 ...   snrs[a,1] <- alphas[a] 
8 ...   bnC       <- tm.bhatNayarCorrelation(nDark, eye, alpha=alphas[a]) 
9 ...   snrs[a,2] <- tm.snr(bnC[[1]], c(38,89)) 
10 ...   snrs[a,3] <- bnC[[1]][89,38] 
11 ... } 
12 tm.dev("figures/bnSNR") 
13 plot(snrs[,1], snrs[,2], main="Modified Bhat-Nayar correlation SNR", 
14 ...      type="b", xlab="alpha", ylab="SNR") 
15 grid() 
16 dev.off() 
17 tm.dev("figures/bnC") 
18 plot(snrs[,1], snrs[,3], main="Modified Bhat-Nayar correlation", 
19 ...      type="b", xlab="alpha", ylab="correlation") 
20 grid() 
21 dev.off()

As we can appreciate from the corresponding plots reported in Figure 5.3, the averaged version of the Bhat-Nayar distance exhibits a better SNR and a better correlation value.


PIC PIC

Figure 5.3: The signal to noise ratio and the maximum correlation value for the modified Bhat-Nayar correlation measure discussed in the text.


The Bhat-Nayar similarity measure is an excellent example of the kind of robustness that we can achieve using ordinal similarity measures: monotone intensity transformation have no impact on the resulting estimates and noise effects are markedly reduced with respect to standard correlation:

1 ia.correlation(ia.realAnimage(nDark),ia.realAnimage(eye))[[4]]
1[1] 0.8974402