Determine Storage Class of Output Files

imwrite uses the following rules to determine the storage class used in the output image.

Storage Class of Image Storage Class of Output Image File

logical

If the output image file format supports 1-bit images, imwrite creates a 1-bit image file.

If the output image file format specified does not support 1-bit images, imwrite exports the image data as a uint8 grayscale image.

uint8

If the output image file format supports unsigned 8-bit images, imwrite creates an unsigned 8-bit image file.

uint16

If the output image file format supports unsigned 16-bit images (PNG or TIFF), imwrite creates an unsigned 16-bit image file.

If the output image file format does not support 16-bit images, imwrite scales the image data to class uint8 and creates an 8-bit image file.

int16

Partially supported; depends on file format.

single

Partially supported; depends on file format.

double

MATLAB® scales the image data to uint8 and creates an 8-bit image file, because most image file formats use 8 bits.

When a file contains multiple images that are related in some way, you can call image processing algorithms directly. For more information, see Work with Image Sequences as Multidimensional Arrays.

If you are working with a large file, you may want to try block processing to reduce memory usage. For more information, see Neighborhood or Block Processing: An Overview.