Skip to content

cornucopia.noise

This module contains transforms that inject noise into an image.

GaussianNoiseFinalTransform

GaussianNoiseFinalTransform(value, **kwargs)

Bases: AddValueTransform

Precomputed Gaussian noise transform

GaussianNoiseTransform

GaussianNoiseTransform(sigma=0.1, *, shared=False, **kwargs)

Bases: NonFinalTransform

Additive Gaussian noise

Parameters:

Name Type Description Default
sigma float

Standard deviation

0.1

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Add the exact same nosie to all channels/images

Final class-attribute instance-attribute

Final = GaussianNoiseFinalTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = GaussianNoiseFinalTransform

The transform type returned by make_final.

RandomGaussianNoiseTransform

RandomGaussianNoiseTransform(sigma=0.1, *, shared=False, shared_noise=None, **kwargs)

Bases: RandomizedTransform

Additive Gaussian noise with random standard deviation

Parameters:

Name Type Description Default
sigma Sampler | float

Distribution from which to sample the standard deviation. If a float, sample from Uniform(0, value). To use a fixed value, pass Fixed(value).

0.1

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Use the same sd for all channels/tensors

shared_noise (channels, tensors, channels + tensors, '', None)

Use the exact same noise for all channels/tensors

Next class-attribute instance-attribute

Next = GaussianNoiseTransform

The transform type returned by make_final(..., max_depth=1).

Final class-attribute instance-attribute

Final = GaussianNoiseFinalTransform

The transform type returned by make_final(..., max_depth=inf).

ChiNoiseTransform

ChiNoiseTransform(sigma=0.1, nb_channels=2, *, shared=False, **kwargs)

Bases: NonFinalTransform

Additive Noncentral Chi noise

(Rician is a special case with nb_channels = 2)

Parameters:

Name Type Description Default
sigma float

Standard deviation

0.1
nb_channels int

Number of independent channels

2

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Add the exact same values to all channels/images

Final class-attribute instance-attribute

Final = ChiNoiseFinalTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = ChiNoiseFinalTransform

The transform type returned by make_final.

RandomChiNoiseTransform

RandomChiNoiseTransform(sigma=0.1, nb_channels=8, *, shared=False, shared_noise=None, **kwargs)

Bases: RandomizedTransform

Additive Chi noise with random standard deviation and channels

Parameters:

Name Type Description Default
sigma Sampler | float

Distribution from which to sample the standard deviation. If a float, sample from Uniform(0, value). To use a fixed value, pass Fixed(value).

0.1
nb_channels Sampler | int

Distribution from which to sample the standard deviation. If a int, sample from RandInt(1, value). To use a fixed value, pass Fixed(value).

8

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Use the same sd for all channels/tensors

shared_noise (channels, tensors, channels + tensors, '', None)

Use the exact same noise for all channels/tensors

Next class-attribute instance-attribute

Next = ChiNoiseTransform

The transform type returned by make_final(..., max_depth=1).

Final class-attribute instance-attribute

Final = ChiNoiseFinalTransform

The transform type returned by make_final(..., max_depth=inf).

GFactorFinalTransform

GFactorFinalTransform(noisetrf, gfactor, **kwargs)

Bases: NonFinalTransform

Multiplicative noise with precomputed noise and g-factor

Parameters:

Name Type Description Default
noisetrf Transform

A transform that applies additive noise

required
gfactor Transform

A transform that takes the noise as input and outputs a g-factor field

required

GFactorTransform

GFactorTransform(noise, shape=5, vmin=0.5, vmax=1.5, order=3, *, shared=False, **kwargs)

Bases: NonFinalTransform

Parameters:

Name Type Description Default
noise Transform

A transform that applies additive noise

required
shape float

Number of control points

5
vmin float

Minimum g-factor

0.5
vmax float

Maximum g-factor

1.5
order int

Spline order

3

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'gfactor', 'noise', 'scalednoise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Use the same field for all channels/tensors

Final class-attribute instance-attribute

Final = GFactorFinalTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = GFactorFinalTransform

The transform type returned by make_final.

GammaNoiseFinalTransform

GammaNoiseFinalTransform(value, **kwargs)

Bases: MulValueTransform

Multiplicative noise with precomputed noise

GammaNoiseTransform

GammaNoiseTransform(sigma=0.1, mean=1, *, shared=False, **kwargs)

Bases: NonFinalTransform

Multiplicative Gamma noise

Parameters:

Name Type Description Default
sigma float

Standard deviation

0.1
mean float

Expected value

1

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Use the exact same noise for all channels/tensors

Final class-attribute instance-attribute

Final = GammaNoiseFinalTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = GammaNoiseFinalTransform

The transform type returned by make_final.

RandomGammaNoiseTransform

RandomGammaNoiseTransform(sigma=0.1, mean=Fixed(1.0), *, shared=False, shared_noise=None, **kwargs)

Bases: RandomizedTransform

Multiplicative Gamma noise with random standard deviation and mean

Parameters:

Name Type Description Default
sigma Sampler or float

Distribution from which to sample the standard deviation. If a float, sample from Uniform(0, value). To use a fixed value, pass Fixed(value).

0.1
mean Sampler or float

Distribution from which to sample the mean. If a float, sample from Uniform(0, value). To use a fixed value, pass Fixed(value).

Fixed(1.0)

Other Parameters:

Name Type Description
returns [list or dict of] {'input', 'output', 'noise'}

Which tensors to return

shared (channels, tensors, channels + tensors, '')

Use the same sd for all channels/tensors

shared_noise (channels, tensors, channels + tensors, '', None)

Use the exact same noise for all channels/tensors

Next class-attribute instance-attribute

Next = GammaNoiseTransform

The transform type returned by make_final(..., max_depth=1).

Final class-attribute instance-attribute

Final = GammaNoiseFinalTransform

The transform type returned by make_final(..., max_depth=inf).