Skip to content

sp_distributionSpDistributionSpDistributionsp_distributionT_sp_distribution🔗

Short description🔗

sp_distributionSpDistributionSpDistributionsp_distributionT_sp_distribution — Generate a salt-and-pepper noise distribution.

Signature🔗

sp_distribution( number PercentSalt, number PercentPepper, out distribution.values Distribution )void SpDistribution( const HTuple& PercentSalt, const HTuple& PercentPepper, HTuple* Distribution )static void HOperatorSet.SpDistribution( HTuple percentSalt, HTuple percentPepper, out HTuple distribution )def sp_distribution( percent_salt: Union[float, int], percent_pepper: Union[float, int] ) -> Sequence[float]

Herror T_sp_distribution( const Htuple PercentSalt, const Htuple PercentPepper, Htuple* Distribution )

static HTuple HMisc::SpDistribution( const HTuple& PercentSalt, const HTuple& PercentPepper )

static HTuple HMisc::SpDistribution( double PercentSalt, double PercentPepper )

static HTuple HMisc.SpDistribution( HTuple percentSalt, HTuple percentPepper )

static HTuple HMisc.SpDistribution( double percentSalt, double percentPepper )

Description🔗

sp_distributionSpDistribution generates a noise distribution with the values 0 and 255. The parameters PercentSaltpercentSaltpercent_salt and PercentPepperpercentPepperpercent_pepper determine the percentage of white and black noise pixels, respectively. The sum of these parameters must be smaller than 100. Usually, the result Distributiondistributiondistribution is used as input for the operator add_noise_distributionAddNoiseDistribution.

Execution information🔗

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

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

  • Processed without parallelization.

Parameters🔗

PercentSaltpercentSaltpercent_salt (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Percentage of salt (white noise pixels).

Default: 5.05.0
Suggested values: 1.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.01.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0
Value range: 0.0 ≤ PercentSalt ≤ 100.0
Minimum increment: 0.1
Recommended increment: 1.0
Restriction: (PercentSalt + PercentPepper) <= 100

PercentPepperpercentPepperpercent_pepper (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[float, int]Htuple (double / Hlong)

Percentage of pepper (black noise pixels).

Default: 5.05.0
Suggested values: 1.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.01.0, 2.0, 5.0, 7.0, 10.0, 15.0, 20.0, 30.0
Value range: 0.0 ≤ PercentPepper ≤ 100.0
Minimum increment: 0.1
Recommended increment: 1.0
Restriction: (PercentSalt + PercentPepper) <= 100

Distributiondistributiondistribution (output_control) distribution.values-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Resulting noise distribution.

Number of elements: 513

Example🔗

(HDevelop)

read_image(Image,'fabrik')
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)\;
create_tuple(&PerSalt,1)\;
set_d(PerSalt,30.0,0)\;
create_tuple(&PerPepper,1)\;
set_d(PerPepper,30.0,0)\;
T_sp_distribution(PerSalt,PerPepper,&Dist)\;
T_add_noise_distribution(Image,&ImageNoise,Dist)\;
disp_image(ImageNoise,WindowHandle)\;

Combinations with other operators🔗

Combinations

Possible successors

add_noise_distributionAddNoiseDistribution

Alternatives

gauss_distributionGaussDistribution, noise_distribution_meanNoiseDistributionMean

See also

gauss_distributionGaussDistribution, noise_distribution_meanNoiseDistributionMean, add_noise_whiteAddNoiseWhite

Module🔗

Foundation