pyBIA.image_moments

Functions

make_moments_table(→ astropy.table.Table)

Compute a full set of image moments and return as an Astropy Table.

calculate_moments(→ list)

Compute raw spatial moments up to 3rd order.

calculate_central_moments(→ list)

Compute central moments up to 3rd order.

calculate_geometrically_centered_moments(→ list)

Compute raw polynomial moments centered on the geometric center of the image grid.

calculate_hu_moments(→ list)

Compute Hu moments using classical eta-normalization.

calculate_legendre_moments(→ list[float])

Compute 2D Legendre moments L_nm for n + m ≤ max_order using orthonormal basis.

zernike_radial_polynomial(→ numpy.ndarray)

Compute the Zernike radial polynomial R_n^m(r).

calculate_zernike_moments(→ list)

Compute the magnitudes of Zernike moments up to a given order.

Module Contents

pyBIA.image_moments.make_moments_table(image: numpy.ndarray) astropy.table.Table[source]

Compute a full set of image moments and return as an Astropy Table.

This function computes raw moments, central moments, Hu moments, geometrically centered polynomial moments, and Legendre moments. It is the main feature-generation function used in pyBIA to build morphology catalogs.

Parameters:

image (ndarray) – 2D array representing a greyscale image.

Returns:

A table with 47 features including raw, central, geometrically centered, Hu, and Legendre moments.

Return type:

astropy.table.Table

pyBIA.image_moments.calculate_moments(image: numpy.ndarray, x: numpy.ndarray = None, y: numpy.ndarray = None, m00: float = None) list[source]

Compute raw spatial moments up to 3rd order.

Parameters:

image (ndarray) – 2D array representing a greyscale image.

Returns:

Raw moments [m00, m10, m01, …, m03].

Return type:

list of float

pyBIA.image_moments.calculate_central_moments(image: numpy.ndarray, x: numpy.ndarray = None, y: numpy.ndarray = None, m00: float = None) list[source]

Compute central moments up to 3rd order.

Parameters:

image (ndarray) – 2D array representing a greyscale image.

Returns:

Central moments [mu00, mu10, …, mu03].

Return type:

list of float

pyBIA.image_moments.calculate_geometrically_centered_moments(image: numpy.ndarray, max_order: int = 3, x: numpy.ndarray = None, y: numpy.ndarray = None) list[source]

Compute raw polynomial moments centered on the geometric center of the image grid.

Parameters:
  • image (ndarray) – 2D array representing a greyscale image.

  • max_order (int, optional) – Maximum total order of the moments (default is 3).

Returns:

Polynomial moments of the form sum(x^p * y^q * image(x,y)) for p+q ≤ max_order, where (x, y) are pixel coordinates shifted so that (0,0) is the geometric center of the image.

Return type:

list of float

pyBIA.image_moments.calculate_hu_moments(image: numpy.ndarray, central_moments=None) list[source]

Compute Hu moments using classical eta-normalization.

Parameters:
  • image (ndarray) – 2D array representing a greyscale image.

  • central_moments (list of float, optional) – Precomputed central moments to third order (10 total: [mu00, mu10, …, mu03]). If not provided, they will be computed from the image.

Returns:

Classical Hu moments [hu1, …, hu7] using eta(p,q) invariants.

Return type:

list of float

pyBIA.image_moments.calculate_legendre_moments(image: numpy.ndarray, max_order: int = 3) list[float][source]

Compute 2D Legendre moments L_nm for n + m ≤ max_order using orthonormal basis.

Parameters:
  • image (ndarray) – 2D array representing a greyscale image.

  • max_order (int) – Maximum total order (n + m) of Legendre moments to compute.

Returns:

Legendre moments up to n+m ≤ max_order.

Return type:

list of float

pyBIA.image_moments.zernike_radial_polynomial(n: int, m: int, r: numpy.ndarray) numpy.ndarray[source]

Compute the Zernike radial polynomial R_n^m(r).

pyBIA.image_moments.calculate_zernike_moments(image: numpy.ndarray, max_order: int = 3, x: numpy.ndarray = None, y: numpy.ndarray = None) list[source]

Compute the magnitudes of Zernike moments up to a given order. Zernike moments are evaluated on a unit disk and their magnitudes are rotationally invariant.

Parameters:
  • image (ndarray) – 2D array representing a greyscale image.

  • max_order (int, optional) – Maximum radial order (n) of the moments (default is 3).

  • x (ndarray, optional) – Precomputed coordinate grids.

  • y (ndarray, optional) – Precomputed coordinate grids.

Returns:

Magnitudes of Zernike moments |Z_nm| for valid (n, m) pairs where n <= max_order.

Return type:

list of float