Image Borders#

Some oneIPL functions operate on user-defined border types. This means that the values of border pixels must be assigned in accordance with the border_types and border_val (optional) parameters specified with the spec parameter.

oneIPL supports the following border types:

The borders are controlled via enum.

enum class oneapi::ipl::border_types : int#

Type of border. Enum values are consistent with IppiBorderType.

Values:

enumerator repl#

Replicated border type.

enumerator wrap#

Wrapped border type.

enumerator mirror#

Mirrored border type, left border: 012… -> 21012…

enumerator mirror_repl#

Replicated mirrored border type, left border: 012… -> 210012…

enumerator default_val#

Constant value border type, border value is max value of corresponding type.

enumerator const_val#

Constant value border type.

enumerator transp#

Outer pixels are not processed.

Replicated Border

This type of border corresponds to the repl value in the border_types enumerator. When using a replicated border, values for border pixels are obtained from the source image boundary pixels, as shown in the figure below. Squares marked in red correspond to pixels copied from the source image ROI. Squares with green values correspond to border pixels, which are replicated from the boundary pixels of the source image.

../_images/GUID-2DF7FF10-8052-4800-9E45-039AC05EB14A-low.jpg

Wrapped Border

This type of border corresponds to the wrap value in the border_types enumerator. When using a wrapped border, values for border pixels are obtained from the source image boundary pixels, as shown in the figure below. Squares marked in red correspond to pixels copied from the source image ROI. Squares with green values correspond to border pixels, which are wrapped from the opposite side of the image.

../_images/GUID-B39EBA55-F5B8-47C3-AD4A-094DED9C065-low.jpg

Mirrored Border

This type of border corresponds to the mirror value in the border_types enumerator. When using a mirrored border, values for border pixels are obtained from the source image boundary pixels, as shown in the figure below. Squares marked in red correspond to pixels copied from the source image ROI. Squares with green values correspond to border pixels, which are mirrored from the source image pixels.

../_images/GUID-B39EBA55-F5B8-47C3-AD4A-094DED9C065E-low.jpg

Mirrored Border with Replication

This type of border corresponds to the mirror_repl value in the border_types enumerator. When using a mirrored border with replication, values for border pixels are obtained from the source image boundary pixels, as shown in the figure below. Squares marked in red correspond to pixels copied from the source image ROI. Squares with green values correspond to border pixels, which are mirrored from the source image pixels while replicating the border.

../_images/GUID-94FDEDFD-410C-4F45-93EB-73E03462BDFE-low.jpg

Default Border

This type of border corresponds to the default_val value in the border_types enumerator. When using a default border, values for all border pixels are set to the constant of the data type default value. In the figure below, this default value is marked as V. Squares marked in red correspond to pixels copied from the source image ROI.

../_images/GUID-E1D4DC2D-67AA-4B09-A374-4ABC9D3CD1EF-low.jpg

Constant Border

This type of border corresponds to the const_val value in the border_types enumerator. When using a constant border, values for all border pixels are set to the constant value specified in the spec parameter of the corresponding function. In the figure below, this constant value is marked as V. Squares marked in red correspond to pixels copied from the source image ROI.

../_images/GUID-E1D4DC2D-67AA-4B09-A374-4ABC9D3CD1EF-low.jpg

Transparent Border

This type of border corresponds to the transp value in the border_types enumerator. When using a transparent border, border pixels are not processed.

Border in Memory

If an ROI is inside an image across any boundary and external pixels the from source image are available, the values are taken from external pixels when the crop flag is crop == crop_types::off. If crop == crop_types::on, the border in memory is not used and pixels are generated according to the border_types enumerator value. In the figure below, squares marked in red correspond to pixels copied from the source image ROI. Squares with black values correspond to source image pixels in memory.

../_images/GUID-F564FF7B-2990-4368-BF7D-047D7F44ED49-low.jpg

Borders in Neighborhood Operations#

The filtering functions described in this section perform neighborhood operations. They operate on the assumption that for each pixel to be processed, all neighborhood pixels required for the operation are also available.

The neighborhood for each pixel must be defined by the filter kernel (or mask) size and anchor cell position. For more information about anchors and how to define the anchor cell position, refer to Neighborhood Operations.

As the following figure illustrates, if the input pixel is near the horizontal or vertical edge of the image, the overlaid kernel may refer to neighborhood pixels that do not exist within the source image and are located outside the image area.

../_images/GUID-32FE13D1-0580-4CC6-9037-BB8A6771B43E-low.jpg

The boundary source image pixels shaded yellow require non-existent pixels to complete the neighborhood operation for the given kernel and anchor. These non-existent pixels shaded gray are external pixels (called border pixels).

If a neighborhood operation is applied to part of a source image, or ROI, then it may be necessary to extend the image area with border pixels depending on the ROI size and position within the image. For ROIs, there are two options to handle borders, switched by crop_types enumeration:

enum class oneapi::ipl::crop_types : int#

Crop types.

Values:

enumerator on#

Crop is applied.

enumerator off#

Crop is not applied.

If boundary pixels are part of ROI, some area of the source image must be extended.

Crop type

Description

on

All ROI borders must be treated according to the specified border type

off

Pixels outside the ROI must be used for calculations when available; otherwise

the specified border type is applied

The figure below illustrates behavior when crop == crop_types::off. If the ROI does not cover yellow (internal boundary) pixels, then internal image pixels outside the ROI are used.

../_images/GUID-F308A1FD-80D0-4C31-9E58-BE8780962D15-low.jpg