slitflow.img.filter module

Classes in this module return filtered images with the same shape as the required image.

class Gauss(info_path=None)[source]

Bases: Image

Apply Gaussian filter to images using cv2.GaussBlur.

Parameters:
  • reqs[0] (Image) – Image stack.

  • param["kernel_size"] (odd integer) – GaussianBlur kernel size.

  • param["split_depth"] (int) – File split depth number.

Returns:

Filtered Image

Return type:

Image

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Apply Gaussian filter to images using cv2.GaussBlur.

Parameters:
  • reqs[0] (numpy.ndarray) – Numpy 3D array with the shape of (frame number, height, width).

  • param["kernel_size"] (odd integer) – GaussianBlur kernel size.

Returns:

Filtered image array

Return type:

numpy.ndarray

class DifferenceOfGaussian(info_path=None)[source]

Bases: Image

Apply the Difference of Gaussian filter for particle detection.

This filter follows the strategy of TrackMate, where sigma_1 and sigma_2 of the DoG filter are determined from the particle diameter. See also trackmate algorithms .

In this class, the particle diameter is set to the size of the Airy disc,

d_psf = (1.22 * wavelength / NA) / pitch.

You can adjust the particle size by multiplying it with size_factor. The wavelength parameter should have the same unit with length_unit.

Parameters:
  • reqs[0] (Image) – Image to apply the filter to. Required parameters; length_unit, pitch.

  • param["wavelength"] (int) – Emission wavelength in length_unit.

  • param["NA"] (float) – Numerical aperture.

  • param["size_factor"] (float, optional) – Particle size factor to multiply PSF size. Defaults to 1.

  • param["split_depth"] (int) – File split depth number.

Returns:

Filtered image object in float32

Return type:

Image

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Apply the Difference of Gaussian filter for particle detection.

Parameters:
  • reqs[0] (numpy.ndarray) – Image to apply the DoG filter to. The image should have the shape of (frame number, height, width).

  • param["dog_sd1"] (float) – Standard deviation of the first Gaussian filter.

  • param["dog_sd2"] (float) – Standard deviation of the second Gaussian filter.

Returns:

Filtered image

Return type:

numpy.ndarray

class LocalMax(info_path=None)[source]

Bases: Image

Local maximum filter for particle images.

Get local maximum values by using maximum_filter in SciPy. Surrounding pixel values except local maximum are set to 0.

Parameters:
  • reqs[0] (DifferenceOfGaussian) – DoG filtered Image to apply this filter to. Required params; d_psf.

  • param["mask_factor"] (float, optional) – Mask size factor to multiply PSF diameter. Defaults to 1.

  • param["split_depth"] (int) – File split depth number.

Returns:

Filtered image object

Return type:

Image

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Local maximum filter for particle images.

Parameters:
  • reqs[0] (numpy.ndarray) – DoG filtered Image to apply the local maximum filter to. The image should have the shape of (frame number, height, width).

  • param["mask_size"] (int) – Mask size factor to multiply PSF diameter.

Returns:

Filtered image

Return type:

numpy.ndarray

class LocalMaxWithDoG(info_path=None)[source]

Bases: Image

Local max image for particle detection with the Difference of Gaussian.

This class is the combination of DifferenceOfGaussian and LocalMax.

You can use this class to skip exporting the result of DifferenceOfGaussian .

Parameters:
  • reqs[0] (Image) – Image to apply the filter to. Required parameters; length_unit, pitch.

  • param["wavelength"] (int) – Emission wavelength in length_unit.

  • param["NA"] (float) – Numerical aperture.

  • param["size_factor"] (float, optional) – Particle size factor to multiply PSF size. Defaults to 1.

  • param["mask_factor"] (float) – Mask size factor to multiply PSF diameter. Defaults to 1.

  • param["split_depth"] (int) – File split depth number.

Returns:

Filtered image object

Return type:

Image

set_info(param={})[source]

Copy info from reqs[0] and add params.

static process(reqs, param)[source]

Local max image for particle detection with the DoG filtering.

Parameters:
  • reqs[0] (numpy.ndarray) – Image to apply the filter to. The image should have the shape of (frame number, height, width).

  • param["dog_sd1"] (float) – Standard deviation of the first Gaussian filter.

  • param["dog_sd2"] (float) – Standard deviation of the second Gaussian filter.

  • param["mask_size"] (int) – Mask size factor to multiply PSF diameter.

Returns:

Filtered image

Return type:

numpy.ndarray