The dilate algorithm performs a two dimensional (2D) filter operation on the input image with the provided 2D boolean kernel. The boolean kernel defines the pixel neighborhood for the filtering operation. The filter is a morphological operation called dilate that is applied to each pixel of the input image masked by the boolean filter. The dilate filter is equivalent to the maximum operation. The dilate operation in a binary image increases or grows the foreground regions (in this case white in the figure below) and identifies and fills holes in objects.
\(K\) is the neighborhood kernel, where \(K \in \{0 \vee 1\}\).
\(k_w, k_h\) are the kernel's width and height, respectively.
\(max\) is the morphological filter operation.
A morphological operation is a set of image processing operations that process digital images based on their shapes. The dilate filter is equivalent to the maximum operation. Dilation extends bright structures in an image. The input may be binary, for the most-common binary morphology, or gray-scale, for the gray morphology. The other morphological filter is the Erode, that is equivalent to the minimum operation. The erode filter can be used after the dilate filter to compose a morphological closing of an image.
Usage
Language:
Import VPI module
import vpi
Define a 3x3 morphological kernel to perform full neighborhood search.
kernel = [[1, 1, 1],
[1, 1, 1],
[1, 1, 1]]
Run morphological filter on input image using the CPU backend and the given kernel. Input and output are VPI images.
Define the kernel to be used. In this case, a simple 3x3 full neighborhood.
int8_t kernel[3 * 3] = { 1, 1, 1,
1, 1, 1,
1, 1, 1 };
Submit the algorithm for the chosen morphological filter to the stream, passing the kernel and other parameters. In this case, the dilate filter. It'll be executed by the CPU backend.