\(\text{SaveImage}\)

You can use the \(\text{SaveImage}\) function to save an image stored in one or more matrices. Note that this function is included as part of the imagefile plug-in and requires the supplied libimagefile library to operate.

You can use the \saveimage backslash command to insert this function.

The following variants of this function are available:

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<pixels>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<luminance>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<pixels>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<channel 1>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<luminance>}, \text{<alpha>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<pixels>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<pixels>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<channel 1>}, \text{<channel 2>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<red>}, \text{<green>}, \text{<blue>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>}, \text{<channel 2>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<red>}, \text{<green>}, \text{<blue>}, \text{<alpha>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>}, \text{<channel 4>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<red>}, \text{<green>}, \text{<blue>}, \text{<alpha>}, \text{<depth (z)>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>}, \text{<channel 4>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>}, \text{<channel 4>}, \text{<channel 5>} \right )\)

  • \(\text{boolean } \text{SaveImage} \left ( \text{<filename>}, \text{<format>}, \text{<bits per pixel>}, \text{<channel 1>}, \text{<channel 2>}, \text{<channel 3>}, \text{<channel 4>}, \text{<channel 5>} \right )\)

The \(\text{<filename>}\) parameter is a text string, encoded as a tuple, holding the name to save the image to.

The \(\text{<format>}\) parameter is a text string, encoded as a tuple, holding the format to apply. The format contains the following letters indicating the meaning of each channel. The number of letters must match the number of channels. Table 41 lists the letters and their meaning.

Table 41 Image Channel Format Codes

Letter

Meaning

r

Red Channel

g

Green Channel

b

Blue Channel

a

Alpha Channel

l

Luminance

d

Depth (z)

If the format is not specified, the format will be determined by the number of channels according to Table 42.

Table 42 Default Formats

Number Channels

Format

1

l

2

la

3

rgb

4

rgba

5

rgbad

The \(\text{<bits per pixel>}\) parameter indicates the depth in bits per pixel. The parameter is only meaningful with certain formats. Typical supported bits-per-pixel values are: 8, 16, 24, and 32. The value -16 indicate 16-bit floating point format. The value -32 indicates 32-bit floating point format.

The parameters \(\text{<luminance>}\), \(\text{<alpha>}\), \(\text{<red>}\), \(\text{<green>}\), \(\text{<blue>}\), \(\text{<depth (z)>}\), \(\text{<channel 1>}\), \(\text{<channel 2>}\), \(\text{<channel 3>}\), \(\text{<channel 4>}\), and \(\text{<channel 5>}\) represent the channel data matrices. Channel data should be represented as real matrices with values ranging from 0 to 1, inclusive.

Figure 201 shows the basic use of the \(\text{SaveImage}\) function.

../_images/save_image_example.png

Figure 201 Example Use Of The SaveImage Function