Skip to content

read_regionReadRegionReadRegionread_regionread_region🔗

Short description🔗

read_regionReadRegionReadRegionread_regionread_region — Read binary images or HALCON regions.

Signature🔗

read_region( out region Region, filename.read FileName )void ReadRegion( HObject* Region, const HTuple& FileName )static void HOperatorSet.ReadRegion( out HObject region, HTuple fileName )def read_region( file_name: str ) -> HObject

Herror read_region( Hobject* Region, const char* FileName )

Herror T_read_region( Hobject* Region, const Htuple FileName )

void HRegion::ReadRegion( const HString& FileName )

void HRegion::ReadRegion( const char* FileName )

void HRegion::ReadRegion( const wchar_t* FileName ) (Windows only)

void HRegion.ReadRegion( string fileName )

Description🔗

The operator read_regionReadRegion reads regions from a binary file.

The following formats are currently supported:

  • HALCON Iconic Object (HOBJ): File format for iconic HALCON objects. The HOBJ file must contain only regions to be readable by read_regionReadRegion. If other objects (e.g., images or XLDs) are stored in the file, an exception is raised. In this case read_objectReadObject can be used to read the corresponding HOBJ file. The HOBJ format is the default file format for regions. Therefore, the extension '.hobj' does not have to be specified when reading or writing the file. See write_objectWriteObject for more information about the HOBJ format.

  • HALCON regions: File format for HALCON regions. This file format supports multiple regions in a single file. The file extension is '.reg'. This format is now legacy and the HOBJ format should be used instead.

  • Tiff: Binary Tiff images with extension '.tiff' or '.tif'. A tiff image can contain any number of regions. The color white is used as foreground.

  • PNG: Binary PNG images with extension '.png'. The result is always one region. The color white is used as foreground.

  • BMP: Binary Windows bitmap images with extension '.bmp'. The result is always one region. The color white is used as foreground.

A search path ('image_dir') can be defined analogous to the operator read_imageReadImage.

Attention🔗

The clipping based on the current image format is set via the operator set_system('clip_region',<'true'/'false'>). Consequently, if no image of sufficient size has been created before the call to read_regionReadRegion, set_system('clip_region','false') should be called before calling read_regionReadRegion to ensure that the region is not being clipped.

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 (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Read region.

FileNamefileNamefile_name (input_control) filename.read → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of the region to be read.

File extension: .hobj, .reg, .tif, .tiff, .png, .bmp

Example🔗

(HDevelop)

* Reading of regions and giving them gray values.
  read_image(Img,'ima_test')
  read_region(Regs,'reg_test')
  reduce_domain(Img,Regs,Res)
(C)
/* Reading of regions and giving them gray values. */
  read_image(&Img,"ima_test")\;
  read_region(&Regs,"reg_test")\;
  reduce_domain(Img,Regs,&Res)\;

Result🔗

If the parameter values are correct the operator read_regionReadRegion returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

read_imageReadImage

Possible successors

reduce_domainReduceDomain, disp_regionDispRegion

See also

write_regionWriteRegion, read_imageReadImage, write_objectWriteObject

Module🔗

Foundation