aspire.noise package

Submodules

aspire.noise.noise module

class aspire.noise.noise.AnisotropicNoiseEstimator(src, bgRadius=1, batchSize=512)

Bases: NoiseEstimator

Anisotropic White Noise Estimator.

Any additional args/kwargs are passed on to the Source’s ‘images’ method

Parameters:
  • src – A Source object which can give us images on demand

  • bgRadius – The radius of the disk whose complement is used to estimate the noise. Radius is relative proportion, where 1 represents the radius of disc inscribing a (src.L, src.L) image.

  • batchSize – The size of the batches in which to compute the variance estimate.

estimate()
Returns:

The estimated noise variance of the images.

estimate_noise_psd()
Returns:

The estimated noise variance of the images in the Source used to create this estimator.

TODO: How’s this initial estimate of variance different from the ‘estimate’ method?

class aspire.noise.noise.BlueNoiseAdder(var, seed=0)

Bases: WhiteNoiseAdder

NoiseAdder where noise power increases with frequency.

Return a WhiteNoiseAdder instance from var and using seed.

Parameters:
  • var – Target noise variance.

  • seed – Optinally provide a random seed used to generate white noise.

class aspire.noise.noise.CustomNoiseAdder(noise_filter, seed=0)

Bases: NoiseAdder

Instantiates a NoiseAdder using the provided noise_filter.

Initialize the random state of this NoiseAdder using noise_filter and seed.

noise_filter will be provided by the user or instantiated automatically by the subclass.

Parameters:
  • seed – The random seed used to generate white noise.

  • noise_filter – An aspire.operators.Filter object. NoiseAdders start by generating gaussian noise, then apply noise_filter to transform the noise. Note the noise_filter will be raised to the 1/2 power.

property noise_var

Return noise variance.

CustomNoiseAdder will estimate noise_var using the noise_filter.

Parameters:

res – Resolution to use when evaluating noise filter, default 512.

Returns:

Noise variance estimated at res.

class aspire.noise.noise.NoiseAdder(noise_filter, seed=0)

Bases: Xform

Defines interface for `CustomNoiseAdder`s.

Initialize the random state of this NoiseAdder using noise_filter and seed.

noise_filter will be provided by the user or instantiated automatically by the subclass.

Parameters:
  • seed – The random seed used to generate white noise.

  • noise_filter – An aspire.operators.Filter object. NoiseAdders start by generating gaussian noise, then apply noise_filter to transform the noise. Note the noise_filter will be raised to the 1/2 power.

abstract property noise_var

Concrete implementations are expected to provide a method that returns the noise variance for the NoiseAdder.

Authors of `NoiseAdder`s are encouraged to consider any relevant methods of calculating noise variance from theory.

class aspire.noise.noise.NoiseEstimator(src, bgRadius=1, batchSize=512)

Bases: object

Noise Estimator base class.

Any additional args/kwargs are passed on to the Source’s ‘images’ method

Parameters:
  • src – A Source object which can give us images on demand

  • bgRadius – The radius of the disk whose complement is used to estimate the noise. Radius is relative proportion, where 1 represents the radius of disc inscribing a (src.L, src.L) image.

  • batchSize – The size of the batches in which to compute the variance estimate.

estimate()
Returns:

The estimated noise variance of the images.

class aspire.noise.noise.PinkNoiseAdder(var, seed=0)

Bases: WhiteNoiseAdder

NoiseAdder where noise power decreases with frequency.

Return a WhiteNoiseAdder instance from var and using seed.

Parameters:
  • var – Target noise variance.

  • seed – Optinally provide a random seed used to generate white noise.

class aspire.noise.noise.WhiteNoiseAdder(var, seed=0)

Bases: NoiseAdder

A Xform that adds white noise, optionally passed through a Filter object, to all incoming images.

Return a WhiteNoiseAdder instance from var and using seed.

Parameters:
  • var – Target noise variance.

  • seed – Optinally provide a random seed used to generate white noise.

classmethod from_snr(snr, signal_power=None, seed=0)

Generates a WhiteNoiseAdder configured to produce a target signal to noise ratio.

When signal_power is not provided, requires_signal_power attribute will be set. Consumers can check this attribute and set signal_power as required. Setting signal_power should then complete building the filter.

Parameters:
  • snr – Desired signal to noise ratio of the returned source.

  • signal_power – Optional, if the signal power is known.

  • seed – Optionally provide a random seed used to generate white noise.

property noise_var

Returns noise variance.

Note in this white noise case, noise variance is known, because the WhiteNoiseAdder was instantied with an explicit variance.

property signal_power
class aspire.noise.noise.WhiteNoiseEstimator(src, bgRadius=1, batchSize=512)

Bases: NoiseEstimator

White Noise Estimator.

Any additional args/kwargs are passed on to the Source’s ‘images’ method

Parameters:
  • src – A Source object which can give us images on demand

  • bgRadius – The radius of the disk whose complement is used to estimate the noise. Radius is relative proportion, where 1 represents the radius of disc inscribing a (src.L, src.L) image.

  • batchSize – The size of the batches in which to compute the variance estimate.

estimate()
Returns:

The estimated noise variance of the images.

Module contents