Write Image to File

Use this tool to write an image to a file. Enter the destination for saving the image at the parameter "File Name". The write operation is applied for each execution of the MVApp.

Execution Behavior

The behavior of this tool regarding the execution differs from the default behavior. Usually a MERLIC tool is executed in the following cases:

  • The MERLIC Vision App is explicitly executed in continuous mode.
  • The MERLIC Vision App is explicitly executed in "Run Once" mode.
  • A MERLIC Vision App with the tool is opened in the MERLIC Creator.
  • A parameter value of the tool has been changed in the MERLIC Creator.

However, the tool "Write Image to File" is only executed in the following cases:

  • The MERLIC Vision App is explicitly executed in continuous mode.
  • The MERLIC Vision App is explicitly executed in "Run Once" mode.

This ensures that write operations are not applied when loading an MVApp or changing a parameter value of the tool.

Parameters

Basic Parameters

Image:

This parameter represents the image which is written to the selected file.

If a color image is used as an input image, all channels of the color image are used for the processing.

File Name:

This parameter defines the name and path of the file in which the image is written. It is set to "Me_Image.png" by default which is located in the directory "%USERPROFILE%\Desktop". You can change the file name and thus the location of the image to be written at the corresponding parameter. If you define a relative file path, the file is searched relative to the default directory "%USERPROFILE%\Desktop". However, if your MVApp was already saved when you define a relative file path, the file is searched relative to the directory in which the MVApp is located.

File Format:

This parameter defines the format in which the image is written to file. It is set to "png none" by default. You can change the format at the corresponding connector.

Value

Description

png none

The image is written in png format without compression. This option is faster than png.

png fastest

The image is written in png format with the fastest compression.

png best

The image is written in png format with the highest compression level.

png

The image is written in png format. This option is slower than png none.

hobj

The image is written in hobj format. HOBJ is a binary file format, which provides the functionality to write and read all kinds of iconic HALCON MVTec HALCON is the comprehensive standard software for machine vision with an integrated development environment (HDevelop). MERLIC makes use of various HALCON procedures and other program functions. objects (images, regions, ...). Since data are written with neither compression nor conversion, writing this file format is faster than other supported file formats in most circumstances. Hence, if an application needs to read and write all kinds of iconic HALCON objects as fast as possible and no compression is required, this format should be used. For images, all HALCON pixel types can be written. Multi-channel images are supported. The channels can have mixed pixel types but must have the same width and height. The domain of an image and its creation date are stored in the file as well. An object tuple is written into a single file.

tiff

The image is written in tiff format.

bmp

The image is written in bmp format.

jpeg

The image is written in jpeg format.

jpeg 100

The image is written in jpeg 100 format.

jpeg 80

The image is written in jpeg 80 format.

jpeg 60

The image is written in jpeg 60 format.

jpeg 40

The image is written in jpeg 40 format.

jpeg 20

The image is written in jpeg 20 format.

ima

The image is written in ima format.

Create Directories:

This parameter defines whether MERLIC creates the directory that is specified in the parameter "File Name" in case it does not exist yet. The parameter is set to 0 by default which means that no directory will be created. If the parameter is set to 1 and the directory that is specified in "File Name" does not exist, MERLIC will create the missing directory as soon as the MVApp is executed.

Additional Parameters

File Prefix:

This parameter defines the string that is added as prefix to the file name when saving the image. It is set to "none" by default. You may either select one of the values provided in the value list of the parameter or you may type a string into the text field of the parameter. This way, can define a custom prefix for the file name. You can also connect the result of a previous tool to this connector if you want to use information of the respective iteration for the prefix.

The following values are available in the value list:

Value

Description

none

No prefix will be added to the file name of the image.

date and time

If this value is set, a prefix that contains the current date and time will be added to the file name. The format of the prefix is the following:

YYYY_MM_DDThh-mm-ss_lll

Example:  2022_08_25T11-15-46_225_Me_Image.png

File Suffix:

This parameter defines the string that is added as suffix to the file name when saving the image. It is set to "none" by default. You may either select one of the values provided in the value list of the parameter or you may type a string into the text field of the parameter. This way, can define a custom suffix for the file name. You can also connect the result of a previous tool to this connector if you want to use information of the respective iteration for the suffix.

The following values are available in the value list:

Value

Description

none

No suffix will be added to the file name of the image.

date and time

If this value is set, a suffix that contains the current date and time will be added to the file name. The format of the suffix is the following:

YYYY_MM_DDThh-mm-ss_lll

Example:  Me_Image_2022_08_25T11-15-46_225.png

Results

Basic Results

Current File Name:

This result contains the name and absolute file path of the image that was saved in the last iteration, e.g., "C:\Users\Public\Documents\MVTec\MERLIC\write_to_file_images\2022_08_25T11-15-46_225_Me_Image.png".

Tool State:

"Tool State" returns information about the state of the tool and thus can be used for error handling. Please see the topic Tool State Result for more information about the different tool state results.

Additional Results

Processing Time:

This result returns the duration of the most recent execution of the tool in milliseconds. The result is provided as additional result. Therefore, it is hidden by default but it can be displayed via the button beside the tool results. For more information see the section Processing Time in the tool reference overview.