salt_pepper_noise

odl.phantom.noise.salt_pepper_noise(vector, fraction=0.05, salt_vs_pepper=0.5, low_val=None, high_val=None, seed=None)[source]

Add salt and pepper noise to vector.

Salt and pepper noise replaces random elements in vector with low_val or high_val.

Parameters:
vectorelement of TensorSpace or ProductSpace

The vector that noise should be added to.

fractionfloat, optional

The propotion of the elements in vector that should be converted to noise.

salt_vs_pepperfloat, optional

Relative abundance of salt (high) vs pepper (low) noise. A high value means more salt than pepper noise.

low_valfloat, optional

The "pepper" color in the noise. Default: minimum value of vector. For product spaces the minimum value per subspace is taken.

high_valfloat, optional

The "salt" value in the noise. Default: maximuim value of vector. For product spaces the maximum value per subspace is taken.

seedint, optional

Random seed to use for generating the noise. For None, use the current seed.

Returns:
salt_pepper_noisevector.space element

vector with salt and pepper noise.