Problem with imwrite a color image
Mostra commenti meno recenti
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 Commenti
Geoff Hayes
il 14 Ago 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
il 14 Ago 2018
I don't think you tried my code below, which DOES work.
Angela
il 14 Ago 2018
Risposta accettata
Più risposte (1)
Walter Roberson
il 14 Ago 2018
1 voto
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 Commenti
Angela
il 14 Ago 2018
Walter Roberson
il 14 Ago 2018
All you need to do is use .png as the file extension when you imwrite()
Walter Roberson
il 15 Ago 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
il 16 Ago 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
il 16 Ago 2018
Walter Roberson
il 16 Ago 2018
.. So write two copies of the image like I suggested, one archive quality and the other reduced bit depth for speed.
Angela
il 16 Ago 2018
Categorie
Scopri di più su Images in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!