imwrite
Writes an image, whose pixel data comes from a matrix, m, with functions defined in the omlimgtoolbox.
Syntax
imwrite(m, file)
imwrite(m, file, ext)
imwrite(m, ..., 'Alpha', alpha, 'Quality', quality, 'WriteMode', mode, ...)
Inputs
- m
- 2-D or N-D matrices with the pixel data for the image to write.
- file
- Name of the image file to write.
- ext (optional)
- Specifies the extension to use for the image file to be written. If this option is used, file should be the base name with no extension specified.
- alpha (optional)
- Name-value pair to specify the alpha channel of the image. If specified, the dimensions of alpha should be the same as m. If not specified, the image is considered to be opaque.
- quality (optional)
- Name-value pair to specify the quality of the image written. Valid values are integers between 0 to 100, with 100 being of the highest quality. If not specified, the default value is 99.
- mode (optional)
- Name-value pair which specifies whether data needs to be appended or overwritten on an existing image file, file. Valid values are overwrite and append, the default option being overwrite.
Examples
addtoolbox('omlimgtoolbox')
m = imread('img_1640.jpg');
imwrite(m, 'oml_img_1640.jpg');
addtoolbox('omlimgtoolbox')
[m, dummy, alpha] = imread('python.png');
imwrite(m, 'oml_img_1640', 'png', 'Alpha', alpha, 'Quality', 85, 'WriteMode', 'overwrite');