Problem with imwrite a color image
Ältere Kommentare anzeigen
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 Kommentare
Geoff Hayes
am 14 Aug. 2018
Angela - what is the data type for your image, Image? Is it necessary to convert to 16-bit unsigned integers? Perhaps try
imwrite(Image, 'image.jpg', 'jpg');
Image Analyst
am 14 Aug. 2018
I don't think you tried my code below, which DOES work.
Angela
am 14 Aug. 2018
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 14 Aug. 2018
1 Stimme
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 Kommentare
Angela
am 14 Aug. 2018
Walter Roberson
am 14 Aug. 2018
All you need to do is use .png as the file extension when you imwrite()
Walter Roberson
am 15 Aug. 2018
Then you will need to get JPEG to change the JPEG standard to permit higher bit depths, and then wait for MATLAB to pick up on the revised standard.
This is rather unlikely to happen.
Image Analyst
am 16 Aug. 2018
The reason jpg is smaller is that it's smaller when you compress more and throw away information. The two lossless formats are bigger because no information is lost. In these days of terabyte solid state drives and 3 GHz computers why are you worried about saving a few kilobytes of drive space? You should be more worried about the fidelity of your image data. Don't save junk just to save a few kilobytes that really won't even matter or make a difference in anything.
Angela
am 16 Aug. 2018
Walter Roberson
am 16 Aug. 2018
.. So write two copies of the image like I suggested, one archive quality and the other reduced bit depth for speed.
Angela
am 16 Aug. 2018
Kategorien
Mehr zu Images finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!