Skip to content

region_to_labelregion_to_labelRegionToLabelRegionToLabelregion_to_labelregion_to_label🔗

Short description🔗

region_to_labelregion_to_labelRegionToLabelRegionToLabelregion_to_labelregion_to_label — Convert regions to a label image.

Signature🔗

region_to_label( region Region, out image ImageLabel, string Type, extent.y Width, extent.x Height )region_to_label( Region : ImageLabel : Type, Width, Height : )void RegionToLabel( const HObject& Region, HObject* ImageLabel, const HTuple& Type, const HTuple& Width, const HTuple& Height )static void HOperatorSet.RegionToLabel( HObject region, out HObject imageLabel, HTuple type, HTuple width, HTuple height )def region_to_label( region: HObject, type: str, width: int, height: int ) -> HObject

Herror region_to_label( const Hobject Region, Hobject* ImageLabel, const char* Type, const Hlong Width, const Hlong Height )

Herror T_region_to_label( const Hobject Region, Hobject* ImageLabel, const Htuple Type, const Htuple Width, const Htuple Height )

HImage HRegion::RegionToLabel( const HString& Type, Hlong Width, Hlong Height ) const

HImage HRegion::RegionToLabel( const char* Type, Hlong Width, Hlong Height ) const

HImage HRegion::RegionToLabel( const wchar_t* Type, Hlong Width, Hlong Height ) const (Windows only)

HImage HRegion.RegionToLabel( string type, int width, int height )

Description🔗

region_to_labelRegionToLabel converts the input regions into a label image according to their index (\(1..n\)), i.e., the first region is painted with the gray value 1, the second the gray value 2, etc. Only positive gray values are used. For byte-images the index is entered modulo 256.

Regions larger than the generated image are clipped appropriately. If regions overlap the regions with the higher image are entered (i.e., they are painted in the order in which they are contained in the input regions). If so desired, the regions can be made non-overlapping by calling expand_regionExpandRegion.

The background, i.e., the area not covered by any regions, is set to 0. This can be used to test in which image range no region is present.

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) → objectobjectHObjectHRegionHObjectHobject

Regions to be converted.

ImageLabelimageLabelimage_label (output_object) image → object (byte / int2 / int4)object (byte / int2 / int4)HObject (byte / int2 / int4)HImage (byte / int2 / int4)HObject (byte / int2 / int4)Hobject * (byte / int2 / int4)

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

Typetypetype (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Pixel type of the result image.

Default: 'int2'"int2"
List of values: 'byte', 'int2', 'int4', 'int8'"byte", "int2", "int4", "int8"

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

Width of the image to be generated.

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

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

Height of the image to be generated.

Default: 512512
Suggested values: 64, 128, 256, 512, 102464, 128, 256, 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_labelRegionToLabel 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, regiongrowingRegiongrowing, connectionConnection, expand_regionExpandRegion

Possible successors

get_grayvalGetGrayval, get_image_pointer1GetImagePointer1

Alternatives

region_to_binRegionToBin, paint_regionPaintRegion

See also

label_to_regionLabelToRegion

Module🔗

Foundation