| MATLAB Function Reference | Search  Help Desk |
| imwrite | Examples See Also |
Write an image to a graphics file
imwrite(A,filename,fmt) imwrite(X,map,filename,fmt) imwrite(...,filename) imwrite(...,Parameter,Value,...)
imwrite(A,filename,fmt)
writes the image in A to filename. filename is a string that specifies the name of the output file, and fmt is a string that specifies the format of the file. If A is a grayscale intensity image or a truecolor (RGB) image of class uint8, imwrite writes the actual values in the array to the file. If A is of class double, imwrite rescales the values in the array before writing, using uint8(round(255*A)). This operation converts the floating-point numbers in the range [0, 1] to 8-bit integers in the range [0, 255].
This table lists the possible values for fmt:imwrite(X,map,filename,fmt)
writes the indexed image in X, and its associated colormap map, to filename. If X is of class uint8, imwrite writes the actual values in the array to the file. If X is of class double, imwrite offsets the values in the array before writing, using uint8(X-1). map must be of class double; imwrite rescales the values in map using uint8(round(255*map)).
imwrite(...,filename)
writes the image to filename, inferring the format to use from the filename's extension. The extension must be one of the legal values for fmt.
imwrite(...,Parameter,Value,...)
specifies parameters that control various characteristics of the output file. Parameters are currently supported for HDF, JPEG, and TIFF files.
This table describes the available parameters for HDF files:| Parameter |
Values |
Default |
'Quality' |
A number between 0 and 100; higher numbers mean quality is better (less image degradation due to compression), but the resulting file size is larger |
75 |
imwrite can write:imwrite(X,map,'flowers.hdf','Compression','none',... 'WriteMode','append')
imfinfo Return information about a graphics file
imread Read image from graphics file