Shapes#

Generate shapes kernels

kerpy.shapes.circle(size=(21, 21), scale=(1, 1), mode='fill')#

Returns a circle kernel of given scale.

Example :
\[\begin{split}\left( \begin{array}{ c, c, c, c, c} 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 & 0 \\ 0 & 0 & 1 & 0 & 0 \end{array} \right)\end{split}\]
Parameters:
  • size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)

  • scale – Tuple defining the width and height of the circle defaults to (1,1)

Returns:

a Kernel object

Return type:

Kernel

kerpy.shapes.cross(size=(21, 21), scale=(1, 1))#

Returns a cross kernel of given scale.

Example :
\[\begin{split}\left(\begin{array}{ c, c, c, c, c} 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \end{array}\right)\end{split}\]
Parameters:
  • size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)

  • scale – Tuple defining the width and height of the cross defaults to (1,1)

Returns:

a Kernel object

Return type:

Kernel

kerpy.shapes.diamond(size=(21, 21), scale=(1, 1), mode='fill')#

Returns a diamond kernel of given scale.

Example :
\[\begin{split}\left( \begin{array}{ c, c, c, c, c} 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 & 0 \\ 0 & 0 & 1 & 0 & 0 \end{array} \right)\end{split}\]
Parameters:
  • size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)

  • scale – Tuple defining the width and height of the diamond defaults to (1,1)

Returns:

a Kernel object

Return type:

Kernel

kerpy.shapes.square(size=(21, 21), scale=(1, 1), mode='fill')#

Returns a square kernel of given scale.

Example :
\[\begin{split}\left(\begin{array}{ c, c, c, c, c} 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{array}\right)\end{split}\]
Parameters:
  • size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)

  • scale – Tuple defining the width and height of the square defaults to (1,1)

Returns:

a Kernel object

Return type:

Kernel

kerpy.shapes.triangle(size=(21, 21), scale=(1, 1))#

Returns a triangle kernel of given scale.

Example :
\[\begin{split}\left( \begin{array}{ c, c, c, c, c} 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 1 & 1 & 0 \\ 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 \end{array} \right)\end{split}\]
Parameters:
  • size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)

  • scale – Tuple defining the width and height of the triangle defaults to (1,1)

Returns:

a Kernel object

Return type:

Kernel