Skip to content

gen_random_regionGenRandomRegionGenRandomRegiongen_random_regiongen_random_regionπŸ”—

Short descriptionπŸ”—

gen_random_regionGenRandomRegionGenRandomRegiongen_random_regiongen_random_region β€” Create a random region.

SignatureπŸ”—

gen_random_region( out region RegionRandom, extent.x Width, extent.y Height )void GenRandomRegion( HObject* RegionRandom, const HTuple& Width, const HTuple& Height )static void HOperatorSet.GenRandomRegion( out HObject regionRandom, HTuple width, HTuple height )def gen_random_region( width: int, height: int ) -> HObject

Herror gen_random_region( Hobject* RegionRandom, const Hlong Width, const Hlong Height )

Herror T_gen_random_region( Hobject* RegionRandom, const Htuple Width, const Htuple Height )

void HRegion::GenRandomRegion( Hlong Width, Hlong Height )

void HRegion.GenRandomRegion( int width, int height )

DescriptionπŸ”—

The operator gen_random_regionGenRandomRegion returns a random region. During this process every pixel in the image area [0…Widthwidthwidth-1] [0…Heightheightheight-1] is adapted into the region with the probability 0.5. The created region can be imagined as the threshold formation in an image with noise.

This procedure is particularly important for the creation of uncorrelated binary patterns.

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

AttentionπŸ”—

If Widthwidthwidth and Heightheightheight are chosen large (\(>\) 100) the created region may require much storage space due to the internally used runlength coding. The gray values of the output region are undefined.

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πŸ”—

RegionRandomregionRandomregion_random (output_object) region β†’ objectHObjectHRegionHObjectHobject *

Created random region with expansion Widthwidthwidth x Heightheightheight.

Widthwidthwidth (input_control) extent.x β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Maximum horizontal expansion of random region.

Default: 128128
Suggested values: 16, 32, 50, 64, 100, 128, 256, 300, 400, 51216, 32, 50, 64, 100, 128, 256, 300, 400, 512
Value range: Width (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Width > 0

Heightheightheight (input_control) extent.y β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Maximum vertical expansion of random region.

Default: 128128
Suggested values: 16, 32, 50, 64, 100, 128, 256, 300, 400, 51216, 32, 50, 64, 100, 128, 256, 300, 400, 512
Value range: Height (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Height > 0

ComplexityπŸ”—

The worst case for the storage complexity for the created region (in byte) is: \(O(Width * Height * 2)\).

ResultπŸ”—

If the parameter values are correct, the operator gen_random_regionGenRandomRegion returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised. The clipping according to the current image format is set via the operator set_system('clip_region',<'true'/'false'>).

Combinations with other operatorsπŸ”—

Combinations

Possible successors

paint_regionPaintRegion, reduce_domainReduceDomain

See also

gen_checker_regionGenCheckerRegion, add_noise_distributionAddNoiseDistribution, add_noise_whiteAddNoiseWhite, reduce_domainReduceDomain

ModuleπŸ”—

Foundation