Image Acquisitionand Proces
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
168 <strong>Image</strong> Acquisition <strong>Proces</strong>sing with LabVIEW<br />
To explain the concept of cross correlation further, consider a source image<br />
matrix of size a ¥ b, and a template image matrix of size c ¥ d (when c £ a and d<br />
£ b). If both the source image and template are normalized, the cross correlation<br />
matrix is populated using the following equation:<br />
b-1<br />
a-1<br />
= ij , ÂÂ ( )( )<br />
xy , ( i+<br />
x) ,( j+<br />
y)<br />
x = 0 y=<br />
0<br />
CrossCorrelationMatrix Template Source<br />
If the images have not been normalized, then we must normalize them by<br />
dividing each element in the respective images by the square root of the sum of its<br />
squares:<br />
CrossCorrelationMatrix<br />
ij ,<br />
=<br />
Ê<br />
Á<br />
Ë<br />
Â<br />
b-1<br />
a-1<br />
ÂÂ<br />
x = 0 y=<br />
0<br />
b-1<br />
a-1<br />
Â<br />
x = 0 y=<br />
0<br />
( Templatexy , )( Source<br />
( i+<br />
x) ,( j+<br />
y)<br />
)<br />
ˆ Ê b-1<br />
a-1<br />
2<br />
2<br />
ˆ<br />
( Templatexy<br />
, )<br />
Source<br />
˜ ÁÂÂ( xy , )<br />
˜<br />
¯ Ë x = 0 y=<br />
0<br />
¯<br />
Consider a cross correlation example with a 3 ¥ 3 template matrix (Table 7.1).<br />
To make the example simpler, let us assume that both the source S xy and template<br />
T xy images have been normalized. Performing the cross correlation between the<br />
images yields:<br />
TABLE 7.1<br />
S 00 S 01 ... ... S 0b<br />
S 10 ... ... ... S 1b T 00 T 01 T 02<br />
... ... ... ... ... T 10 T 11 T 12<br />
... ... ... ... ... T 20 T 21 T 22<br />
S a0 S a1 ... ... S ab<br />
Some values used in the cross correlation are undeÞned (i.e., those cells on<br />
the right and bottom of the matrix), and are consequently set to zero for calculations.<br />
This makes Þnding matches of a partial template near the edges unlikely.<br />
As you might imagine from the equation matrix shown previously, performing<br />
a cross correlation on large images can take some time, although increasing the size<br />
of the template will make the routine even slower. Also, if the rotation of the template<br />
is not known, the cross correlation will need to be repeated at a range of angles to<br />
achieve rotation-invariant matches.<br />
7.1.2.2 Scale Invariant and Rotation Invariant Matching<br />
One of cross correlation’s biggest ßaws is its inability to match objects in a source<br />
image that are either a different size to the template, or have been rotated. If this