Problem with imwrite a color image
조회 수: 24 (최근 30일)
이전 댓글 표시
I am trying to save the output color image of a program as a jpg or png file. I have tried
outfile='image.jpg'
imwrite(im2uint16(Image),outfile,'BitDepth',12,'Mode','lossless','Quality',100)
When i tried to open this using Gimp or ImageMagick , the image could not open, it was not recognized. Can anyone suggest the right way to save a color image as a jpg using imwrite? Thank you.
댓글 수: 4
채택된 답변
Image Analyst
2018년 8월 14일
Photoshop doesn't recognize it either. But this works:
rgbImage = imread('peppers.png');
outfile='image.jp2' % JPEG 2000
imwrite(im2uint16(rgbImage),outfile,'Mode','lossless')
And I'd recommend you use PNG rather than JPG or JPEG2000 (jp2).
PNG has pretty much become the widespread de facto standard.
댓글 수: 8
Walter Roberson
2018년 8월 15일
편집: Walter Roberson
2018년 8월 15일
writejpg>set_jpeg_props would never be called for file extension .png .
If you go the dual-file route, then
imwrite(im2uint16(rgbImage), 'newimage.png'); %for archive quality
imwrite(im2uint8(rgbImage), 'newimage.jpg'); %for quick access that is not archive quality
추가 답변 (1개)
Walter Roberson
2018년 8월 14일
JPEG does not support 16 bit images. Some JPEG libraries support 12 bit images.
JPEG XR supports 16 bit images, but MATLAB does not support JPEG XR.
댓글 수: 8
Walter Roberson
2018년 8월 16일
.. So write two copies of the image like I suggested, one archive quality and the other reduced bit depth for speed.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!