Hey @grant
I could reproduce the issue in MATLAB R2023a. Upon further investigation I found that standard image viewers, such as XnViewMP and IrfanView, do not support 12-bit JPEG images due to limited adoption of this format in common software and hardware. Most image viewers widely use 8-bit JPEGs or 16-bit formats like TIFF for higher bit depth.
As a workaround I suggest using the “imread” and “imshow” function to view the 12-bit monochrome JPG image in MATLAB.
Please refer to the following example:
x = [1003 647 1011; 668 982 677; 977 678 973];
y = uint16(x);
imwrite(y, 'example.jpg', 'BitDepth', 12, 'Quality', 100);
img = imread('example.jpg');
imshow(img, []);
Alternatively, the 12-bit monochrome image can be saved in an uncompressed TIFF format.
Modify the “imwrite” function as follows:
imwrite(y, 'example.tiff', 'Compression', 'none');
For more information regarding “imwrite” function, kindly refer the following documentation: