clearex.segmentation.otsu

Functions

difference_of_gaussian(vol[, sigma_high, ...])

Apply Difference of Gaussian (DoG) filter to a 3D volume and threshold using Otsu's method.

gamma_otsu(image_data[, gamma, ...])

Apply gamma correction and Otsu thresholding to a 3D image.

noise_normalized_otsu(image_data[, ...])

Normalized Otsu Thresholding for 3D images.

otsu(image_data[, down_sampling])

Apply Otsu thresholding to a 3D image.

clearex.segmentation.otsu.difference_of_gaussian(vol, sigma_high=50, sigma_low=200, down_sampling=4, n_classes=3)

Apply Difference of Gaussian (DoG) filter to a 3D volume and threshold using Otsu’s method.

Parameters:
  • vol (np.ndarray) – A 3D NumPy array of shape (Z, Y, X).

  • sigma_high (Optional[float]) – The standard deviation of the high-pass Gaussian kernel.

  • sigma_low (Optional[float]) – The standard deviation of the low-pass Gaussian kernel.

  • down_sampling (Optional[int]) – The factor to downsample the image data by.

  • n_classes (Optional[int]) – The number of classes to threshold the image data into. Default is 3.

Returns:

The binary image data.

Return type:

np.ndarray

clearex.segmentation.otsu.otsu(image_data, down_sampling=4)

Apply Otsu thresholding to a 3D image.

Parameters:
  • image_data (np.ndarray) – The image data to threshold.

  • down_sampling (int) – The factor to downsample the image data by.

Returns:

image_binary – The binary image data.

Return type:

np.ndarray

clearex.segmentation.otsu.noise_normalized_otsu(image_data, down_sampling=4)

Normalized Otsu Thresholding for 3D images.

Identifies the threshold for the image data using Otsu’s method and normalizes the image data by subtracting the threshold and dividing by the standard deviation.

Parameters:
  • image_data (np.ndarray) – The image data to threshold and normalize.

  • down_sampling (int) – The factor to downsample the image data by.

Returns:

The normalized image data.

Return type:

np.ndarray

clearex.segmentation.otsu.gamma_otsu(image_data, gamma=0.5, gaussian_kernel=1, down_sampling=4)

Apply gamma correction and Otsu thresholding to a 3D image.

Applies a gamma correction to the image data, followed by a Gaussian blur, Otsu thresholding, dilation, erosion, and a final Gaussian filter.

Parameters:
  • image_data (np.ndarray) – The image data to threshold and normalize.

  • gamma (float) – The gamma value to apply to the image data.

  • gaussian_kernel (float) – The standard deviation of the Gaussian kernel to apply to the image data.

  • down_sampling (int) – The factor to downsample the image data by.

Returns:

The thresholded image data.

Return type:

np.ndarray