Functions to read and save images. The governing philosophy is to retain all the precision of the file format during loading, and to choose a format capable of representing in-memory images during save operations.
The file format is automatically determined, and the returned Image has a precision large enough to represent the contents of the file. Practically, this means that images with 8 bits per channel (including color-mapped images) are read in as Fractional images, and all others are read in as Float images.
Most popular file formats are recognized and read in correctly. The following file formats can be read:
Name of file to be loaded (string)
Index of subimage (for multi-image files)
fileName = 'image.tif' image = ice.Load(fileName)
Save image to file using specified format. If a format is not specified, an appropriate choice will be used. This function throws ice.error for failure.
Name of file to save to (string).
Output format (int). Can be one of:
Note: It is worth mentioning that dithering is not done automatically while saving to a lower-precision format.
c = ice.Card(ice.constants.FLOAT, [1.0, 0.5, 0.3]) fileName = 'image.tif' format = ice.constants.FMT_TIFFFLOAT c.Save(fileName, format)
The FMT_JPEG format looks at the image's meta-data dictionary to determine the "quality" factor of the output image. The "quality" of a JPEG image is a number between 1 and 100.
c = ice.Card(ice.constants.FLOAT, [1.0, 0.5, 0.3]) fileName = "image.jpg" format = ice.constants.FMT_JPEG c.SetMetaDataItem('JPEG_QUALITY', 50) c.Save(fileName, format)