Skip to content

region_to_binRegionToBinRegionToBinregion_to_binregion_to_bin🔗

Short description🔗

region_to_binRegionToBinRegionToBinregion_to_binregion_to_bin — Convert a region into a binary byte-image.

Signature🔗

region_to_bin( region Region, out image BinImage, integer ForegroundGray, integer BackgroundGray, extent.x Width, extent.y Height )void RegionToBin( const HObject& Region, HObject* BinImage, const HTuple& ForegroundGray, const HTuple& BackgroundGray, const HTuple& Width, const HTuple& Height )static void HOperatorSet.RegionToBin( HObject region, out HObject binImage, HTuple foregroundGray, HTuple backgroundGray, HTuple width, HTuple height )def region_to_bin( region: HObject, foreground_gray: int, background_gray: int, width: int, height: int ) -> HObject

Herror region_to_bin( const Hobject Region, Hobject* BinImage, const Hlong ForegroundGray, const Hlong BackgroundGray, const Hlong Width, const Hlong Height )

Herror T_region_to_bin( const Hobject Region, Hobject* BinImage, const Htuple ForegroundGray, const Htuple BackgroundGray, const Htuple Width, const Htuple Height )

HImage HRegion::RegionToBin( Hlong ForegroundGray, Hlong BackgroundGray, Hlong Width, Hlong Height ) const

HImage HRegion.RegionToBin( int foregroundGray, int backgroundGray, int width, int height )

Description🔗

region_to_binRegionToBin converts the input region given in Regionregionregion into a byte-image and assigns a gray value of ForegroundGrayforegroundGrayforeground_gray to all pixels in the region. If the input region is larger than the generated image, it is clipped at the image borders. The background is set to BackgroundGraybackgroundGraybackground_gray.

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🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

Regions to be converted.

BinImagebinImagebin_image (output_object) image → object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject * (byte)

Result image of dimension Width * Height containing the converted regions.

ForegroundGrayforegroundGrayforeground_gray (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Gray value in which the regions are displayed.

Default: 255255
Suggested values: 0, 1, 50, 100, 128, 150, 200, 254, 2550, 1, 50, 100, 128, 150, 200, 254, 255
Value range: 0 ≤ ForegroundGray ≤ 255 (lin)
Recommended increment: 1

BackgroundGraybackgroundGraybackground_gray (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Gray value in which the background is displayed.

Default: 00
Suggested values: 0, 1, 50, 100, 128, 150, 200, 254, 2550, 1, 50, 100, 128, 150, 200, 254, 255
Value range: 0 ≤ BackgroundGray ≤ 255 (lin)
Recommended increment: 1

Widthwidthwidth (input_control) extent.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the image to be generated.

Default: 512512
Suggested values: 256, 512, 1024256, 512, 1024
Value range: 1 ≤ Width ≤ 1024 (lin)
Minimum increment: 1
Recommended increment: 16
Restriction: Width >= 1

Heightheightheight (input_control) extent.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the image to be generated.

Default: 512512
Suggested values: 256, 512, 1024256, 512, 1024
Value range: 1 ≤ Height ≤ 1024 (lin)
Minimum increment: 1
Recommended increment: 16
Restriction: Height >= 1

Complexity🔗

\(O(2*\textrm{Height}*\textrm{Width})\).

Result🔗

region_to_binRegionToBin always returns 2 (H_MSG_TRUE). The behavior in case of empty input (no regions given) can be set via set_system('no_object_result',<Result>) and the behavior in case of an empty input region via set_system('empty_region_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

thresholdThreshold, connectionConnection, regiongrowingRegiongrowing, pouringPouring

Possible successors

get_grayvalGetGrayval

Alternatives

region_to_labelRegionToLabel, paint_regionPaintRegion, set_grayvalSetGrayval

See also

gen_image_protoGenImageProto, paint_grayPaintGray

Module🔗

Foundation