# Comparing Two Matrix Notation

I have two matrix A and B, I want to find pattern B in matrix A. So I get 2 pattern similar like pattern B. What the name of this operation? and How I write this in mathematics notation?

• Assuming everything is binary, you compute the spatial convolution of $A$ under filter $B$, and are counting the number of times the convolution is at least the sum of the elements in $B$. – cdipaolo Jan 28 at 1:12
Ordinary template matching (aka cross correlation) does not work in your case, because that would also consider the white points of the template, not only the black points. Chamfer-Matching, instead, only sums the distance transform values of A at the black points of B. If '1' stands for black, and D is the distance transform of A, and B is centered such that its midpoint has coordinate $$(0,0))$$, then Chamfer-Matching computes the following image C:
$$C(x,y) = \sum_{dx,dy} D(x+dx, y+dy)\cdot B(dx, dy)$$