deeptrack.math Module#

Mathematical operations and structures.

This module provides classes and utilities to perform common mathematical operations and transformations on images, including clipping, normalization, blurring, and pooling. These are implemented as subclasses of Feature for seamless integration with the feature-based design of the library.

Module Structure#

Classes:

  • Clip: Clip the input values within a specified minimum and maximum range.

  • NormalizeMinMax: Perform min-max normalization on images.

  • NormalizeStandard: Normalize images to have mean 0 and

    standard deviation 1.

  • NormalizeQuantile: Normalize images based on specified quantiles.

  • Blur: Apply a blurring filter to the image.

  • AverageBlur: Apply average blurring to the image.

  • GaussianBlur: Apply Gaussian blurring to the image.

  • MedianBlur: Apply median blurring to the image.

  • Pool: Apply a pooling function to downsample the image.

  • AveragePooling: Apply average pooling to the image.

  • MaxPooling: Apply max pooling to the image.

  • MinPooling: Apply min pooling to the image.

  • MedianPooling: Apply median pooling to the image.

  • Resize: Resize the image to a specified size.

  • BlurCV2: Apply a blurring filter using OpenCV2.

  • BilateralBlur: Apply bilateral blurring to preserve edges while smoothing.

Example#

Define a simple pipeline with mathematical operations:

>>> import numpy as np
>>> from deeptrack import math

Create features for clipping and normalization:

>>> clip = math.Clip(min=0, max=200)
>>> normalize = math.NormalizeMinMax()

Chain features together:

>>> pipeline = clip >> normalize

Process an input image:

>>> input_image = np.array([0, 100, 200, 400])
>>> output_image = pipeline(input_image)
>>> print(output_image)
[0., 0.5, 1., 1.]

Classes#

Average([features, axis])

Average of input images

AverageBlur([ksize])

Blur an image by computing simple means over neighbourhoods.

AveragePooling([ksize])

Apply average pooling to an images.

BilateralBlur([d, sigma_color, sigma_space])

Blur an image using a bilateral filter.

Blur(filter_function[, mode])

Apply a blurring filter to an image.

BlurCV2(*args, **kwargs)

Clip([min, max])

Clip the input within a minimum and a maximum value.

Feature([_input])

Base feature class.

GaussianBlur([sigma])

Applies a Gaussian blur to images using Gaussian kernels for image augmentation.

Image(value[, copy])

Wrapper for array-like values with property tracking.

MaxPooling([ksize])

Apply max pooling to images.

MedianBlur([ksize])

Applies a median blur to images by replacing each pixel with the median of its neighborhood.

MedianPooling([ksize])

Apply median pooling to images.

MinPooling([ksize])

Apply min pooling to images.

NormalizeMinMax([min, max, featurewise])

Image normalization.

NormalizeQuantile([quantiles, featurewise])

Image normalization.

NormalizeStandard([featurewise])

Image normalization.

Pool(pooling_function[, ksize])

Downsamples the image by applying a function to local regions of the image.

Resize([dsize])

Resize an image to a specified size.