Input and Output
Input and Output
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.
- Load(fileName, subImageIndex = 0)
- fileName: Name of file to be loaded (string)
subImageIndex: Index of subimage (for multi-image files)
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:
fileName = 'image.tif' image = ice.Load(fileName)
- Save(fileName, outputFormat)
- fileName: Name of file to save to (string).
outputFormat: Output format (int). Can be one of:
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.
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)