Image Borders
Contents
Image Borders#
Some of the oneIPL image processing functions operate on
user-defined border types. It means that the values of border pixels must be
assigned in accordance with the border_type
(or border) and border_val
(optional)
parameters, specified in the algorithmic spec
.
oneIPL supports the following border types:
The borders must be 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.
-
enumerator repl#
Replicated Border
This type of border shall correspond to the repl
value in the
border_types
enumerator. When using a replicated border, values for
border pixels shall be obtained from the source image boundary pixels, as
shown in the figure below. Squares marked in red shall correspond to pixels
copied from the source image ROI. Squares with green values
shall correspond to border pixels, which must be replicated from the boundary
pixels of the source image.
Wrapped Border
This type of border shall correspond to the wrap
value in the
border_types
enumerator. When using a wrapped border, values for
border pixels shall be obtained from the source image boundary pixels, as
shown in the figure below. Squares marked in red shall correspond to pixels
copied from the source image ROI. Squares with green values
shall correspond to border pixels that must be taken from the source image.
Mirrored Border
This type of border shall correspond to the mirror
value in the
border_types
enumerator. When using a mirrored border, values for
border pixels shall be obtained from the source image boundary pixels, as
shown in the figure below. Squares marked in red shall correspond to pixels
copied from the source image ROI. Squares with green values
shall correspond to border pixels, which must be mirrored from the source image
pixels.
Mirrored Border with Replication
This type of border shall correspond to the mirror_repl
value in the
border_types
enumerator. When using a mirrored border with
replication, values for border pixels shall be obtained from the source
image boundary pixels, as shown in the figure below. Squares marked
in red shall correspond to pixels copied from the source image ROI. Squares
with green values shall correspond to border pixels, which must be mirrored
from the source image pixels. The difference of this border type from
the mirrored border is that the anchor cell value shall be replicated to
the border pixels.
Default Border
This type of border shall correspond to the default_val
value in the
border_types
enumerator. When using a default border, values for
all border pixels shall be set to the constant value equal to corresponding
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.
Constant Border
This type of border shall correspond to the const_val
value in the
border_types
enumerator. When using a constant border, values for
all border pixels shall be 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.
Transparent Border
This type of border shall correspond to the transp
value in the
border_types
enumerator. When using a transparent border, border
pixels are not processed.
Border in Memory
If ROI is inside image across any boundary and external pixels from source image are available,
the values shall be taken from external pixels if crop flag is crop == crop_types::off
.
If crop == crop_types::on
, the border in memory is not used and pixels must be 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.
Borders in Neighborhood Operations#
Filtering functions described in this section shall perform neighborhood operations. They shall 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 given 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.
The set of all boundary source image pixels that require such non-existent pixels to complete the neighborhood operation for the given kernel and anchor is shaded yellow, while the collection of all scanned external pixels (called border pixels) is shaded gray.
If the neighborhood operation is needed to be applied to the part of the
source image, or ROI, then the necessity of extending the image area
with border pixels shall depend on the ROI size and position within the
image. There are two options to handle borders in case of ROI, which
can be switched by crop_types
enumeration in algorithm specification:
-
enum class oneapi::ipl::crop_types : int#
Crop types.
Values:
-
enumerator on#
Crop is applied.
-
enumerator off#
Crop is not applied.
-
enumerator on#
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 ROI must be used for calculations when available. Otherwise specified border type is applied |
The figure below illustrates behavior when crop == crop_types::off
.
If ROI does not cover yellow (internal boundary) pixels, then
internal image pixels outside ROI shall be used.