florin.ndnt

N-Dimensional Neighborhood Thresholding for any-dimensional data.

Functions

ndnt
Binarize data with N-Dimensional Neighborhood Thresholding.
integral_image
Compute the integral image of a n image or volume.
integral_image_sum
Compute the neighborhood sum of an integral image.

Classes

InvalidThresholdError

Functions

integral_image(img[, inplace]) Compute the integral image of an image or image volume.
integral_image_sum(int_img[, shape, …]) Compute pixel neighborhood statistics.
ndnt(img[, shape, threshold, inplace]) Compute an n-dimensional Bradley thresholding of an image or volume.

Exceptions

InvalidThresholdError(t) Raised when the NDNT threshold value is out of domain.
exception florin.ndnt.InvalidThresholdError(t)[source]

Raised when the NDNT threshold value is out of domain.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

florin.ndnt.integral_image(img, inplace=False)[source]

Compute the integral image of an image or image volume.

Parameters:
  • img (array-like) – The original 2D image or 3D volume.
  • inplace (bool, optional) – If True, compute the integral image in the same array as the original image.
Returns:

int_img – The integral image of the original image or volume.

Return type:

array-like

Notes

This function extends the integral image to n dimensions as described in [1].

References

[1]Tapia, E., 2011. A note on the computation of high-dimensional integral images. Pattern Recognition Letters, 32(2), pp.197-201.
florin.ndnt.integral_image_sum(int_img, shape=None, return_counts=True)[source]

Compute pixel neighborhood statistics.

Parameters:
  • int_image (array_like) – The integral image.
  • shape (tuple of int) – The shape of the neighborhood around each pixel.
  • return_counts (bool) – If True, in addition to neighborhood pixel sums, return the number of pixels used to compute each sum.
Returns:

  • sums (array_like) – An array where each entry is the sum of pixel values in a neighborhood. The same shape as int_img.
  • counts (array_like) – An array where each entry is the number of pixels used to compute each entry in sums. The same shape as int_img.

florin.ndnt.ndnt(img, shape=None, threshold=0.25, inplace=False)[source]

Compute an n-dimensional Bradley thresholding of an image or volume.

The Bradley thresholding, also called Local Adaptive Thresholding, uses the integral image of an image or volume to threshold an image based on local mean greyscale intensities. The underlying assumption is that while the mean intensity may shift, the distribution of intensities will remain roughly constant across an entire image or volume.

Parameters:
  • img (array-like) – The image to threshold.
  • shape (array-like, optional) – The dimensions of the local neighborhood around each pixel/voxel.
  • threshold (float) – The threshold value as the percentage of greyscale value to keep. Must be in [0, 1].

Notes

The original Bradley thresholding was introduced in [1] as a means for quickly thresholding images or video. Shahbazi et al. [2] extended this method to operate on data of arbitrary dimensionality using the method described by Tapia [3].

References

[1]Bradley, D. and Roth, G., 2007. Adaptive thresholding using the integral image. Journal of Graphics Tools, 12(2), pp.13-21.
[2]Shahbazi, E., Kinnison, J., et al.
[3]Tapia, E., 2011. A note on the computation of high-dimensional integral images. Pattern Recognition Letters, 32(2), pp.197-201.