Differentials#
Generate differential kernels
- kerpy.diff.central(orient_x: bool = 0, orient_y: bool = 0, size: tuple[int, int] = (3, 3)) Kernel #
Returns a complex kernel corresponding to the central finite difference. The signs depend on the orient_x and orient_y args. Interesting to compute an image gradient.
- Example :
- \[\begin{split}\left(\begin{array}{ c, c, c} 0 + 0j & 0 + -1j & 0 + 0j \\ -1 + 0j & 0 + 0j & 1 + 0j \\ 0 + 0j & 0 + 1j & 0 + 0j \end{array}\right)\end{split}\]
- Parameters:
orient_x (1|0) – Goes forward in the x direction if 0 else goes backwards, defaults to 0
orient_y (1|0) – Goes forward in the y direction if 0 else goes backwards, defaults to 0
size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)
- Raises:
AssertionError – orient must belongs {0,1}
- Returns:
a Kernel object
- Return type:
- kerpy.diff.finite(orient_x: bool = 0, orient_y: bool = 0, flip: bool = True) Kernel #
Returns a complex 3x3 kernel that corresponds to finite forward or backward difference. Interesting to compute an image gradient using the finite difference.
- Examples :
- \[\begin{split}\left(\begin{array}{ c, c, c} 0 + 0j & 0 + -1j & 0 + 0j \\ -1 + 0j & 1 + 1j & 0 + 0j \\ 0 + 0j & 0 + 0j & 0 + 0j\end{array}\right)\end{split}\]
- Parameters:
orient_x (1|0) – Goes forward in the x direction if 0 else goes backward, defaults to 0
orient_y (1|0) – Goes forward in the y direction if 0 else goes backward, defaults to 0
flip (boolean) – Flip the kernel, defaults to True
- Raises:
AssertionError – orient must belongs {0,1}
- Returns:
a complex Kernel object
- Return type:
- kerpy.diff.laplacian(mode='diamond') Kernel #
Return a real kernel corresponding to the Laplacian kernel. Interesting to compute an image Laplacian.
- Examples :
- \[\begin{split}\left(\begin{array}{ c, c, c} 0 & -1 & 0 \\ -1 & 4 & -1 \\ 0 & -1 & 0 \end{array}\right)\end{split}\]
- Parameters:
mode ("diamond"|"square") – Set the variant method for the Laplacian operator
- Returns:
a real Kernel object
- Return type:
- kerpy.diff.prewitt(orient_x: bool = 0, orient_y: bool = 0, size: tuple[int, int] = (3, 3)) Kernel #
Returns a complex kernel corresponding to the central finite difference with multiple lines, also called Prewitt operator. The signs depend on the orient_x and orient_y args. Interesting to compute an image gradient with a lower noise.
- Example :
- \[\begin{split}\left(\begin{array}{ c, c, c} -1 + -1j & 0 + -1j & 1 + -1j \\ -1 + 0j & 0 + 0j & 1 + 0j \\ -1 + 1j & 0 + 1j & 1 + 1j \end{array}\right)\end{split}\]
- Parameters:
orient_x (1|0) – Goes forward in the x direction if 0 else goes backwards, defaults to 0
orient_y (1|0) – Goes forward in the y direction if 0 else goes backwards, defaults to 0
size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)
- Raises:
AssertionError – orient must belongs {0,1}
- Returns:
a Kernel object
- Return type:
- kerpy.diff.robert_cross(orient_x: bool = 0, orient_y: bool = 0) Kernel #
Returns a 2x2 complex kernel corresponding to the Robert cross operator. The signs depend on the orient_x and orient_y args. Interesting to compute an image gradient with a higher noise.
- Example :
- \[\begin{split}\left( \begin{array}{ c, c} -1 + 0j & -0 + -1j \\ 0 + 1j & 1 + 0j \end{array} \right)\end{split}\]
- Parameters:
orient_x (1|0) – Goes forward in the x+y direction if 0 else goes backwards, defaults to 0
orient_y (1|0) – Goes forward in the x-y direction if 0 else goes backwards, defaults to 0
- Raises:
AssertionError – orient must belongs {0,1}
- Returns:
a Kernel object
- Return type:
- kerpy.diff.sobel(orient_x: bool = 0, orient_y: bool = 0, size: tuple[int, int] = (3, 3)) Kernel #
Returns a complex kernel corresponding to the Sobel operator, which is Prewitt plus the finite central. The signs depend on the orient_x and orient_y args. Interesting to compute an image gradient with a lower noise.
- Example :
- \[\begin{split}\left( \begin{array}{ c, c, c} -1 + -1j & 0 + -2j & 1 + -1j \\ -2 + 0j & 0 + 0j & 2 + 0j \\ -1 + 1j & 0 + 2j & 1 + 1j \end{array} \right)\end{split}\]
- Parameters:
orient_x (1|0) – Goes forward in the x direction if 0 else goes backwards, defaults to 0
orient_y (1|0) – Goes forward in the y direction if 0 else goes backwards, defaults to 0
size ((int, int)) – Tuple defining the size of the kernel respectively in the x and y direction, defaults to (3,3)
- Raises:
AssertionError – orient must belongs {0,1}
- Returns:
a Kernel object
- Return type: