add_gaussian_noise

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

add_gaussian_noise(array: ndarray, sigma: float, rng: Generator, mask: ndarray | None = None, round_to_int: bool = False) → ndarray[source]

Return a copy of array with zero-mean Gaussian noise added.

Following MIRP, the noise is added to the WHOLE image by default (the ROI only determines sigma); pass mask to restrict the addition to the region of interest.

Parameters:
  • array – Image voxel array in (z, y, x) order.

  • sigma – Noise standard deviation in intensity units; 0 returns an unmodified copy.

  • rng – Random generator supplying the noise field.

  • mask – Optional ROI selector; noise is added only where mask > 0.

  • round_to_int – Round the result to whole numbers, mirroring MIRP’s handling of integer-valued CT (HU) data.

Returns:

The perturbed array as float64, same shape as array.