In binary morphology, an image is viewed as a subset of a Euclidean space <math>\mathbb{R}^d</math> or the integer grid <math>\mathbb{Z}^d</math>, for some dimension d. Let us denote this space or grid by E.
A structuring element is a simple, pre-defined shape, represented as a binary image, used to probe another binary image, in morphological operations such as erosion, dilation, opening, and closing.
Let <math>C</math> and <math>D</math> be two structuring elements satisfying <math>C\cap D=\emptyset</math>. The pair (C,D) is sometimes called a composite structuring element. The hit-or-miss transform of a given image A by B=(C,D) is given by:
That is, a point x in E belongs to the hit-or-miss transform output if C translated to x fits in A, and D translated to x misses A (fits the background of A).
Some applications
Thinning
Файл:HitOrMiss.svgThe structuring elements Ci, Di, Bi as described in the text. The top two rows show the pairings of C1+D1, and C2+D2. The bottom two rows show how B1-B8 are generated by rotating (C1+D1) and (C2+D2). The numbering of B1-B8 are arbitrary. (White pixels are not included in any of these sets, and are shown only to keep the spacing intelligible. Red and Blue pixels identify set membership only, and do not represent a pixel's actual color value.)
Let <math>E=\mathbb{Z}^2</math>, and consider the eight composite structuring elements, composed of:
<math>C_1=\{(0,0),(-1,-1),(0,-1),(1,-1)\}</math> and <math>D_1=\{(-1,1),(0,1),(1,1)\}</math>,
<math>C_2=\{(-1,0),(0,0),(-1,-1),(0,-1)\}</math> and <math>D_2=\{(0,1),(1,1),(1,0)\}</math>
and the three rotations of each by 90°, 180°, and 270°. The corresponding composite structuring elements are denoted <math>B_1,\ldots,B_8</math>.
For any i between 1 and 8, and any binary image X, define
Pattern detection. By definition, the hit-or-miss transform indicates the positions where a certain pattern (characterized by the composite structuring element B) occurs in the input image.
Pruning. The hit-or-miss transform can be used to identify the end-points of a line to allow this line to be shrunk from each end to remove unwanted branches.