SHRINK4 filter

The SHRINK4 filter is a standard binary filter which works in a 3x3 environment.

The SHRINK4 filter assigns a 1 to a true center pixel only when all four horizontal and vertical neighbours are true as well. When one or more horizontal or vertical neighbours are 0, a 0 is assigned. When the center pixel is zero, it always remains zero.

The result of using the SHRINK4 filter is that areas of true pixels 'shrink' along their edges; single lines of true pixels and single true pixels totally surrounded by false pixels disappear.

  

Input:

Output:

Example:

When the center pixel is true and all horizontal and vertical neighbours are true:

  

0

1

0

1

1

1

0

1

0

a binary filter orders these values as below (bit position) where 0 means the last position, 1 the one but last position, etc.:

  

5

6

7

4

8

0

3

2

1

  

This results in the following binary number: 101010101

(this binary number is equivalent to: 2 to the power 8 + 2 to the power 6 + 2 to the power 4 + 2 to the power 2 + 2 to the power 0 = 256 + 64 + 16 + 4 + 1 = 341)

The answer is looked up in the table which is built in in the binary filter itself. In case of the SHRINK4 filter the output value is 1.

When looked up in the table of the SHRINK8 filter (this filter only assigns a 1 when all neighbours are true as well), the output value is 0.

See also: