MATLAB: Does IMWRITE support lossy compression for 16 bit data in MATLAB 7.4 (R2007a)

16-bit88-bitbitMATLAB

I would like to know if I can use IMWRITE with 16 bit data to write images with lossy compression. When I run the code:
X = uint16(65535 * rand(1024,1024));
imwrite(X,'noise.jpg','jpeg','BitDepth',16,'Mode','lossy','Quality',75);
??? Error using ==> imagesci\private\writejpg at 61
Lossy compression not supported for 16 bit data.

Best Answer

The JPEG standard does not allow lossy compression when working with 16-bit data. As a result, 16-bit lossy compression is not supported by IMWRITE.
To work around this issue, use 16-bit lossless compression or convert the data to 8-bit and then use 8-bit lossy compression with IMWRITE.