imwritecv
Writes an image, whose pixel data comes from a matrix that can be referenced by imagedata.
Syntax
imwritecv(file, imagedata)
imwrite(file, imagedata, options)
Inputs
- file
- Name of the image file to write.
- imagedata
- Handle of an image generated by the ComputerVision library or a real 2D/3D/4D matrix.
- options (optional)
- Different options for writing file. options
should be a vector, specifying one or more of the options below, followed by its value.
If any of the options are not applicable or valid, imwritecv will
ignore it, using default values. No errors/warnings will be reported. Valid options are:
- 1
- Jpeg image quality where a higher value indicates better quality; values are 0-100 with a default of 95.
- 2
- Enables/disables writing image as a progressive jpeg; values are 0(default) or 1.
- 3
- Enables/disables jpeg optimization; values are 0(default) or 1.
- 4
- Specifies jpeg restart interval; values are 0(default)-65535.
- 5
- Specifies jpeg luma quality; values are 0(default) - 100.
- 6
- Specifies jpeg chroma quality; values are 0(default) - 100.
- 16
- Specifies compression for png images; values are 0-9 with a default of 1.
- 17
- Specifies the strategy used for writing png images; values are listed below:
- 0
- Used for normal data with the best speed setting.
- 1
- Used for data from a filter/predictor, that has small values with a random distribution.
- 3(default)
- Limits match distances to 1 (full length encoding).
- 4
- Prevents dynamic Huffman codes, simpler decoder for special applications..
- 18
- Specifies binary level for png images; values are 0(default) or 1.
- 32
- Specifies binary format flag for PPM/PGM/PBM; 0 or 1(default).
- (3 << 4) + 0
- Storage types for OpenEXR image files; values are listed below:
- 1
- Stores images as HALF (FP16).
- 2(default)
- Store images as FP32.
- (3 << 4) + 1
- Compression options for OpenEXR image files, overriding OPENEXR storage types; values are listed below:
- 0
- No compression.
- 1
- Run length encoding.
- 2
- Zlib compression with one scan line at a time.
- 3
- Zlib compression with blocks of 16 scan lines.
- 4
- Piz-based wavelet compression.
- 5
- Lossy 24-bit float compression.
- 6
- Lossy 4-by-4 pixel block compression, fixed compression rate.
- 7
- Lossy 4-by-4 pixel block compression, flat fields compression.
- 8
- Lossy DCT based compression, block of 32 scanlines; efficient for partial buffer access.
- 9
- Lossy DCT based compression, block of 256 scanlines; efficient space wise and faster decoding for full frames.
- 64
- Overrides compression type for OpenEXR image files; values are 1-100, with 3(Zip compression) as a default.
- 128
- Flags for 'TUPETYPE' field of PAM files. Valid values are listed below:
- 0
- No format specified.
- 1
- Black and white image.
- 2
- Grayscale image.
- 3
- Gray scale image with alpha channel.
- 4
- RGB image.
- 5
- RBA image with alpha channel.
- 256
- Tiff file option for DPI resolution unit: see libtiff documentation for valid values.
- 257
- Tiff file option for X direction DPI: see libtiff documentation for valid values.
- 258
- Tiff file option for Y direction DPI: see libtiff documentation for valid values.
- 259
- Tiff file option for compressionI: see libtiff documentation for valid values.
Examples
Write an image with the default options:
cvhandle = imreadcv('image1.png');
imwritecv('image1_compose.png', cvhandle);
Write an image with jpeg quality option
cvhandle = imreadcv('image1.jpg');
imwritecv('image1_with_opts.jpg', cvhandle, [1 100]);
Write out just the red channel data of an image:
cvhandle = imreadcv('image1.jpg');
m = getcv(handle); % Gets the 3D matrix
m1 = m(:,:,1); % Get the first slice - red
imwritecv('red1.jpg', m1);