Operator FIRkernelNxM

Operator Library: Filter

The operator FIRkernelNxM creates rectangular kernel window around each pixel, which includes the neighbor pixels. The size of the kernel can be defined by editing the output link. N represents the number of kernel rows and M the number of kernel columns.

[Note] No FIR filter

In contrast to its name, the operator has nothing to do with a FIR filter. It can be used to produce the filter input data.

Other operators to generate kernels are the operators LineNeighboursNx1 and PixelNeighbours1xM.

The central element of a kernel always represents the original input pixel of the respective position. The output image O with pixel indices x and y and kernel indices m and n is derived from the input by:

with and

At image edges, no neighbored pixels are defined. The operator allows the definition of the required edge handling algorithm using the parameter EdgeHandling.

For kernels of even size, there is no central pixel. In this case, the central pixel is displaced to the upper left corner, e.g. for a kernel of size 4x4 defines the central pixel at (1,1) as can be seen in the following table.

0,0 0,1 0,2 0,3
1,0 1,1 1,2 1,3
2,0 2,1 2,2 2,3
3,0 3,1 3,2 3,3

Kernels are described by the number of rows and columns. In VisualApplets, N represents the number of rows, and M represents the number of columns. Often, kernel elements are addressed by their index instead of their coordinate. In this case, the order is row by row as shown in the following table.

0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15

The following example shows the resulting composition for three kernel rows and three kernel columns. The 3x3 matrix in the depicted operator provides the relative addressing that defines the content of the respective kernels. Each 3x3 cluster on the output shows the different kernel values per pixel.

Instead of kernel configurations per pixel, this example shows the resulting subkernels: the first kernel at index 0 and the last kernel at index 8.

The following example shows the resulting composition for two kernel rows and two kernel columns. As the relative addresses only reference neighbors on the right hand side or below, no edge handling needs to be performed for content to the left or at top.

Comparing the last two examples with odd and even kernel sizes shows a noticeable behavior of the edgeHandling feature in edgeMirroring mode. While edgeMirroring for even and odd kernel sizes is treated identically on top and left borders, it produces slightly different results on the bottom and the right hand side. Due to the large output image size only the resulting configurations for the first, upper right, and last, lower right, input pixel with their resulting values per kernel are presented:

EdgeMirroring for odd kernel sizes fills regions with missing data from equidistant regions with data. The border is preserved and not replicated. The same principle is valid for filling regions to the top or to the left for even kernel sizes. In contrast to this, filling regions to the bottom or to the right replicates the border during mirroring. Again, this only occurs for even kernel sizes.

[Tip] EdgeMirroring for even kernel sizes

For even kernel sizes, filling regions to the bottom or to the right replicates the border during mirroring.

Technically, the operator waits and buffers the required pixels of the kernel until they can be output in parallel. Therefore, the operator will cause a delay as pixels can only be output after all required respective neighbor pixels were processed at the input. The line delay is:

Operator Restrictions

  • ImageWidth < 2*Parallelism is not allowed.

  • Empty images, i.e. images with no pixels, are not allowed.

  • Empty lines or varying line lengths are not allowed.

I/O Properties

Property Value
Operator Type M
Input Link I, data input
Output Link O, kernel output

Supported Link Format

Link Parameter Input Link I Output Link O
Bit Width any1 as I
Arithmetic {unsigned, signed} as I
Parallelism {1, 2, 4, 8, 16, 32, 64} as I
Kernel Columns 1 any2
Kernel Rows 1 any3
Img Protocol {VALT_IMAGE2D, VALT_LINE1D}4 as I
Color Format any as I
Color Flavor any as I
Max. Img Width any as I
Max. Img Height any as I

1

The range of the input bit width is:

  • For unsigned inputs: [1, 64]

  • For signed inputs: [2, 64]

  • For unsigned color inputs: [3, 63]

  • For signed color inputs: [6, 63].

4

If VALT_LINE1D image protocol is used, the operator is of type P instead of type M.

2

OutputKernelColumns <= ImageWidth

3

OutputKernelRows <= ImageHeight

Parameters

EdgeHandling
Type static parameter
Default EdgeMirrored
Range {EdgeMirrored, EdgeConstant}

At image edges, no neighbors exist to generate a kernel. In this case, the operator can be used in two edge handling modes:

In mode EdgeMirrored, mirrored pixels are used at the image edges.

In mode EdgeConstant, the missing kernel elements at the edges are filled by a constant value. This value can be defined using the parameter Constant.

Constant
Type static parameter
Default 0
Range range of input link I

If the parameter EdgeHandling is set to EdgeConstant, this parameter defines the default value for a pixel outside the image borders.

For color formats, the value is an unsigned integer combining the binary representations of all color components.

Examples of Use

The use of operator FIRkernelNxM is shown in the following examples: