make_noise_image#
- photutils.datasets.make_noise_image(shape, distribution='gaussian', mean=None, stddev=None, seed=None)[source]#
Make a noise image containing Gaussian or Poisson noise.
This function simply takes random samples from a Gaussian or Poisson distribution with the given parameters. If you want to apply Poisson noise to existing sources, see the
apply_poisson_noisefunction.- Parameters:
- shape2-tuple of int
The shape of the output 2D image.
- distribution{‘gaussian’, ‘poisson’}, optional
The distribution used to generate the random noise:
'gaussian': Gaussian distributed noise.'poisson': Poisson distributed noise.
- meanfloat
The mean of the random distribution. Required for both Gaussian and Poisson noise.
- stddevfloat, optional
The standard deviation of the Gaussian distribution. Required for Gaussian noise and ignored for Poisson noise (the variance of the Poisson distribution is equal to its mean).
- seedint, optional
A seed to initialize the
numpy.random.BitGenerator. IfNone, then fresh, unpredictable entropy will be pulled from the OS.
- Returns:
- image2D
ndarray Image containing random noise. The dtype is float for Gaussian noise and int for Poisson noise.
- image2D
- Raises:
See also
Examples
import matplotlib.pyplot as plt from photutils.datasets import make_noise_image # Make Gaussian and Poisson noise images shape = (100, 100) image1 = make_noise_image(shape, distribution='gaussian', mean=0., stddev=5.) image2 = make_noise_image(shape, distribution='poisson', mean=5.) # Plot the images fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) ax1.imshow(image1, origin='lower') ax1.set_title(r'Gaussian noise ($\mu=0$, $\sigma=5.$)') ax2.imshow(image2, origin='lower') ax2.set_title(r'Poisson noise ($\mu=5$)')
(
Source code,png,hires.png,pdf,svg)