ImageDev

MorphologicalKernel2d

Represents a 3x3 kernel dedicated to be applied on a binary image. Each kernel element can be assigned to one of three different values.

A 2D morphological kernel contains exactly 9 values and indexes matching the following table: $$ \begin{bmatrix} 4 & 3 & 2\\ 5 & 0 & 1\\ 6 & 7 & 8 \end{bmatrix} $$ Accepted values for the kernel are:

Syntax

Method Description
Ptr New( Value value = ZERO ) Constructor returning a kernel with all elements initialized with the same value
  • value: the value to assign.
  • Value getValue( int index ) get the value of a specific kernel's element at the position index
  • index: the position of the kernel's element between 0 and 8.
  • void setValue( int index, Values value ) Assigns a value to a specific kernel's element
  • index: the position of the kernel's element between 0 and 8.
  • value: the value to assign.
  • void setAllValues(Values value = ZERO ) Assigns the same value to all kernel elements.
  • value: the default value for all of a kernel's elements.
  • void rotate( size_t rotation = 1 ) Applies a direct rotation of a PI/4 multiple to the kernel.
    $$ \begin{array}{ccc} \begin{bmatrix} 4 & 3 & 2\\ 5 & 0 & 1\\ 6 & 7 & 8 \end{bmatrix} & \text{ =>} & \begin{bmatrix} 3 & 2 & 1\\ 4 & 0 & 8\\ 5 & 6 & 7 \end{bmatrix} \end{array} $$
  • rotation: the number of rotations of PI/4.
  • Method Description
    MorphologicalKernel2d(value) Constructor returning a kernel with all elements initialized with the same value
  • value: the value to assign.
  • get_value(index) get the value of a specific kernel's element at the position index
  • index: the position of the kernel's element between 0 and 8.
  • set_value(index, value) Assigns a value to a specific kernel's element
  • index: the position of the kernel's element between 0 and 8.
  • value: the value to assign.
  • set_all_values(value) Assigns the same value to all kernel elements.
  • value: the default value for all of a kernel's elements.
  • rotate(rotation) Applies a direct rotation of a PI/4 multiple to the kernel.
    $$ \begin{array}{ccc} \begin{bmatrix} 4 & 3 & 2\\ 5 & 0 & 1\\ 6 & 7 & 8 \end{bmatrix} & \text{ =>} & \begin{bmatrix} 3 & 2 & 1\\ 4 & 0 & 8\\ 5 & 6 & 7 \end{bmatrix} \end{array} $$
  • rotation: the number of rotations of PI/4.
  • Method Description
    public MorphologicalKernel2d(Values initValue) Constructor returning a kernel with all elements initialized with the same value
  • value: the value to assign.
  • Value GetValue(int index) get the value of a specific kernel's element at the position index
  • index: the position of the kernel's element between 0 and 8.
  • void SetValue(int index, Values value) Assigns a value to a specific kernel's element
  • index: the position of the kernel's element between 0 and 8.
  • value: the value to assign.
  • void SetAllValues(Values value) Assigns the same value to all kernel elements.
  • value: the default value for all of a kernel's elements.
  • void Rotate(int rotation) Applies a direct rotation of a PI/4 multiple to the kernel.
    $$ \begin{array}{ccc} \begin{bmatrix} 4 & 3 & 2\\ 5 & 0 & 1\\ 6 & 7 & 8 \end{bmatrix} & \text{ =>} & \begin{bmatrix} 3 & 2 & 1\\ 4 & 0 & 8\\ 5 & 6 & 7 \end{bmatrix} \end{array} $$
  • rotation: the number of rotations of PI/4.