stouputils.data_science.data_processing.image.curvature_flow_filter module#

curvature_flow_filter_image(image: ndarray[Any, dtype[Any]], time_step: float = 0.05, number_of_iterations: int = 5, ignore_dtype: bool = False) ndarray[Any, dtype[Any]][source]#

Apply a curvature flow filter to an image.

Parameters:
  • image (NDArray[Any]) – Image to apply the curvature flow filter

  • time_step (float) – Time step for the curvature flow filter

  • number_of_iterations (int) – Number of iterations for the curvature flow filter

  • ignore_dtype (bool) – Ignore the dtype check

Returns:

Image with the curvature flow filter applied

Return type:

NDArray[Any]

>>> ## Basic tests
>>> image = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=np.uint8)
>>> filtered = curvature_flow_filter_image(image, 0.05, 5)
>>> filtered.tolist()[0][0]
1.2910538407309702
>>> filtered.shape == image.shape
True
>>> filtered.dtype == image.dtype
False
>>> rgb = np.full((3,3,3), 128, dtype=np.uint8)
>>> rgb[1,1] = [50, 100, 150]
>>> filtered_rgb = curvature_flow_filter_image(rgb, 0.05, 5)
>>> filtered_rgb.shape == (3,3,3)
True
>>> ## Test invalid inputs
>>> curvature_flow_filter_image("not an image")
Traceback (most recent call last):
        ...
AssertionError: Image must be a numpy array
>>> curvature_flow_filter_image(image, time_step="not a float")
Traceback (most recent call last):
        ...
AssertionError: time_step must be a float
>>> curvature_flow_filter_image(image, number_of_iterations="not an integer")
Traceback (most recent call last):
        ...
AssertionError: number_of_iterations must be an integer