Herror ::read_image (
    Hobject *Image,
    const HTuple &FileName
)
HImage HImage::ReadImage (
    const HTuple &FileName
)

Read an image with different file formats.

The operator ::read_image reads the indicated image files from the background storage and generates the image. One or more files can be indicated. The region of the generated image object (= all pixels of the matrix) is maximal chosen.

All images files written by the operator ::write_image (format 'ima') have the extension '.ima'. A description file can be available for every image in HALCON format (same file name with extension '.exp'). The type of the pixel data (byte, int4, real) can also be taken from the description file. If this information is not available the type byte is used as presetting.

Besides the HALCON format TIFF, GIF, BMP, PCX, SUN-Raster, PGM, PPM, PBM and XWD files can also be read. The gray values of PBM images are set at the values 0 and 255. The file formats are either recognized by the extension (if indicated) or because of the internal structure of the files. If the extension is indicated the image can be found faster. In case of PGM, PPM and PBM the corresponding extension (e.g. 'pgm') or the general value 'pnm' can be used. In case of TIFF 'tiff' and 'tif' are accepted. In case of colored images an image with three color channels (matrices) is created, the red channel being stored in the first, the blue channel in the second and the green channel in the third component (channel number).

Image files are searched in the current directory (determined by the environment variable) and in the image directory of HALCON . The image directory of HALCON is preset at '.' and '/usr/local/halcon/images' in a UNIX environment and can be set via the operator ::set_system. More than one image directory can be indicated. This is done by separating the individual directories by a colon.

Furthermore the search path can be set via the environment variable HALCONIMAGES (same structure as 'image_dir'). Example:

setenv HALCONIMAGES "/usr/images:/usr/local/halcon/images"

HALCON also searches images in the subdirectory "images" (Images for the program examples). The environment variable HALCONROOT is used for the HALCON directory.


Attention

Images of the types int4 and real generally cannot be exchanged between different types of computers.


Parameters

Image (output_object)
image -> Hobject * : HImage ( byte / int4 / real )

FileName (input_control)
filename(-array) -> HTuple.char *
Default value: 'fabrik'
Suggested values: 'monkey', 'fabrik', 'mreut'


Example
/* Reading an image: */
  read_image(&Image,"mreut") ;

/* Reading 3 images into an image object: */
  Htuple Files ;
  create_tuple(&Files,3) ;
  set_s(Files,"house_red",0) ;
  set_s(Files,"house_green",1) ;
  set_s(Files,"house_blue",2) ;
  T_read_image(&Bildobjekt,Files) ;

/* Setting of search path for images on '/mnt/images' and '/home/images': */
  set_system("image_dir","/mnt/images:/home/images") ;

Result

If the parameters are correct the operator ::read_image returns the value H_MSG_TRUE. If the indicated files cannot be found ::read_image returns the value H_MSG_FAIL. Otherwise an exception handling is raised.


Possible Successors

::disp_image, ::threshold, ::regiongrowing, ::count_channels, ::decompose3, ::class_ndim_norm, ::gauss_image, ::fill_interlace, ::zoom_image_size, ::zoom_image_factor, ::crop_part, ::write_image, ::rgb1_to_gray


Alternatives

::read_sequence


See also

::set_system, ::write_image


Module

Image / region / XLD management



Copyright © 1996-2002 MVTec Software GmbH