write_image ( Image : : Format, FillColor, FileName : )

Write images in graphic formats.

The operator write_image returns the indicated image (Image) in different image formats in files. Pixels outside the region receive the color defined by FillColor. For gray value images a value between 0 (black) and 255 (white) must be passed, with RGB color images the RGB values can be passed directly as a hexadecimal value: e.g., 0xffff00 for a yellow background (red=255, green=255, blue=0).

The following formats are currently supported:

'tiff':
TIFF format, 3-channel-images (RGB): 3 samples per pixel;
other images (grayvalue images): 1 sample per pixel, 8 bits
per sample, uncompressed,72 dpi; file extension: *.tif

'bmp':
Windows-BMP format, 3-channel-images (RGB): 3 bytes per pixel;
other images (gray value image): 1 byte per pixel;
file extension: *.bmp

'jpeg':
JPEG format (lossy compression); together with the format string
the quality value determining the compression rate can be provided: 
e.g., 'jpeg 30'.  Attention: images stored for being processed later
should not be compressed with the jpeg format according to the lost of
information.

'png':
PNG format (lossless compression); together with the format string,
a compresion level between 0 and 9 can be specified, where 0
corresponds to no compression and 9 to the best possible
compression.  Alternatively, the compression can be selected with
the following strings: 'best', 'fastest', and 'none'.  Hence,
examples for correct parameters are 'png', 'png 7', and 'png none'.
Images of type byte and uint2 can be stored in PNG files.  If an
image with a reduced domain is written, the region is stored as the
alpha channel, where the points within the domain are stored as the
maximum gray value of the image type and the points outside the
domain are stored as the gray value 0.  If an image with a full
domain is written, no alpha channel is stored.

'ima'
The data is written binary line by line (without header or carriage return).
The size of the image and the pixel type are stored
in the description file "FileName.exp".
byte, int2, uint2, int4 and
real images can be written.
The file extension is: *.ima


Parameters

Image (input_object)
image(-array) -> object : byte / direction / cyclic / int1 / int2 / uint2 / int4 / real
Output image(s).

Format (input_control)
string -> string
Graphic format.
Default value: 'tiff'
List of values: 'tiff', 'bmp', 'jpeg', 'ima', ''jpeg 100'', ''jpeg 80'', ''jpeg 60'', ''jpeg 40'', ''jpeg 20'', ''png'', ''png best'', ''png fastest'', ''png none''

FillColor (input_control)
integer -> integer
Fill gray value for pixels not belonging to the image region.
Default value: 0
Suggested values: -1, 0, 255, '0xff0000', '0xff00'

FileName (input_control)
filename(-array) -> string
Name of graphic file.


Result

If the parameter values are correct the operator write_image returns the value 2 (H_MSG_TRUE). Otherwise an exception handling is raised. If the file cannot be opened write_image returns 5 (H_MSG_FAIL).


Parallelization Information

write_image is processed under mutual exclusion against itself and without parallelization.


Possible Predecessors

open_window, read_image


Module

Image / region / XLD management



Copyright © 1996-2005 MVTec Software GmbH