MATLAB Answers

imwrite doesnt work help

3 views (last 30 days)
Huseyin
Huseyin on 23 Sep 2016
Answered: Steven Lord on 23 Sep 2016
Hi,
I have a grayscale image with size '3520x4280 uint8'. Now I want to compress this image with imwrite by using 'Compression' tool. I call;
imwrite(image1,'test.jpg','Compression','rle');
However I get this error message:
Error using writejpg>set_jpeg_props (line 173)
Expected input to match one of these strings:
quality, comment, bitdepth, mode
The input, ''compression'', did not match any of the valid strings.
Error in writejpg (line 50)
props = set_jpeg_props(data,varargin{:});
Error in imwrite (line 473)
feval(fmt_s.write, data, map, filename, paramPairs{:});
I use MatlabR2013a. Does anyone know what I missed? Thanks a lot

Answers (1)

Steven Lord
Steven Lord on 23 Sep 2016
Looking at the documentation for imwrite it appears that the 'Compression' parameter is only supported with HDF5 or TIFF, and only HDF5 supports 'rle' compression. My guess is that you tried to adapt an example that wrote an HDF5 file to write a .jpg file, but forgot or didn't realize that you needed to remove the 'Compression' arguments.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!