Skip to content

add_noise_distributionAddNoiseDistributionAddNoiseDistributionadd_noise_distributionT_add_noise_distributionπŸ”—

Short descriptionπŸ”—

add_noise_distributionAddNoiseDistributionAddNoiseDistributionadd_noise_distributionT_add_noise_distribution β€” Add noise to an image.

SignatureπŸ”—

add_noise_distribution( image Image, out image ImageNoise, distribution.values Distribution )void AddNoiseDistribution( const HObject& Image, HObject* ImageNoise, const HTuple& Distribution )static void HOperatorSet.AddNoiseDistribution( HObject image, out HObject imageNoise, HTuple distribution )def add_noise_distribution( image: HObject, distribution: Sequence[float] ) -> HObject

Herror T_add_noise_distribution( const Hobject Image, Hobject* ImageNoise, const Htuple Distribution )

HImage HImage::AddNoiseDistribution( const HTuple& Distribution ) const

HImage HImage.AddNoiseDistribution( HTuple distribution )

DescriptionπŸ”—

add_noise_distributionAddNoiseDistribution adds noise distributed according to Distributiondistributiondistribution to the Imageimageimage. The resulting gray values are clipped to the range of the corresponding pixel type.

The Distributiondistributiondistribution is stored in a tuple of length 513. The individual values of this tuple define the frequency of noise with a specific amplitude defined by the position within the tuple. The central value, i.e., the value at the position 256 in the tuple defines the frequency of pixels that are not changed. The value at the position 255 defines the frequency of pixels for which the grayvalue is decreased by 1. The value at the position 254 defines the respective frequency for a grayvalue decrease of 2, and so on. Analogously, the value at position 257 defines the frequency of pixels for which the grayvalue is increased by 1.

The Distributiondistributiondistribution represents salt and pepper noise if at most one value at a position smaller than 256 is not equal to zero and at most one value at a position larger than 256 is not equal to zero. In case of salt and pepper noise, the added noisy pixels are set to the minimum (pepper) and maximum (salt) values that can be represented by ImageNoiseimageNoiseimage_noise if the amount of pepper is indicated by the value at position 0 and the amount of salt is indicated by the value at position 512 in the tuple.

The random noise is generated using the C function β€œdrand48()”. See the parameter 'seed_rand'"seed_rand" of set_systemSetSystem for information on the used random seed.

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image(-array) β†’ object (byte / int2)HObject (byte / int2)HImage (byte / int2)HObject (byte / int2)Hobject (byte / int2)

Input image.

ImageNoiseimageNoiseimage_noise (output_object) (multichannel-)image(-array) β†’ object (byte / int2)HObject (byte / int2)HImage (byte / int2)HObject (byte / int2)Hobject * (byte / int2)

Noisy image.

Number of elements: ImageNoise == Image

Distributiondistributiondistribution (input_control) distribution.values-array β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Noise distribution.

Number of elements: 513

ExampleπŸ”—

(HDevelop)


read_image(Image,'mreut')
dev_display (Image)
sp_distribution(30,30,Dist)
add_noise_distribution(Image,ImageNoise,Dist)
dev_display (ImageNoise)
(C)
read_image(&Image,"fabrik")\;
disp_image(Image,WindowHandle)\;
set_d(PerSalt,30.0,0)\;
set_d(PerPepper,30.0,0)\;
T_sp_distribution(PerSalt,PerPepper,&Dist)\;
T_add_noise_distribution(Image,&ImageNoise,Dist)\;
disp_image(ImageNoise,WindowHandle)\;

ResultπŸ”—

add_noise_distributionAddNoiseDistribution returns 2 (H_MSG_TRUE) if all parameters are correct. If the input is empty the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

gauss_distributionGaussDistribution, sp_distributionSpDistribution, noise_distribution_meanNoiseDistributionMean

Alternatives

add_noise_whiteAddNoiseWhite

See also

sp_distributionSpDistribution, gauss_distributionGaussDistribution, noise_distribution_meanNoiseDistributionMean, add_noise_whiteAddNoiseWhite

ModuleπŸ”—

Foundation