Problem with PNG Image (grayscale): 12 bits from 16 bits
10 views (last 30 days)
Show older comments
Hi,
I´m working in a project to get images from DDSM ( http://marathon.csee.usf.edu/Mammography/Database.html). I´ve got the step to convert (LJPEG to LJPEG.1) and now I´m with the step to convert LJPEG.1 to PNG, but the problem is the PNG image must be of 12 bits (because the original image of DDSM has 12 bits).
I know it´s not possible to obtain directly a 12 bit image from PNG, so I´ve used 2 ways:
- Divide the matrix by 16. e.g. I4=I3/16;
- Shift the image 4 positions. e.g. I5=bitshift (I3,-4);
With this two options, I get the same result, a matrix with max(I5(:)) = 4095, so the process is OK and I could see it in a figure, but the problem comes when I want to save in a png file, because the image must be saved in 16-bit and get me a dark image with a big size (four times the 8 bit png image). I also checked the value of bits: 13, 14, 15 and 16 and their values are 0.
I´ve used the PNG option of 'SignificantBits' with 12, but I obtained the same result.
Any ideas to solve the problem? I´ve found many articles about it but any of them gives a solution.
Thanks & Regards
Alejo
2 Comments
Image Analyst
on 27 Jun 2012
I believe Ashish Uthama is the "image format guy" at the Mathworks. Try calling him if he doesn't answer here. I think he might hang out at the newsgroup more than there so try there also. Steve Eddins also has been willing to answer format questions on occasion in the past.
Cheng Zhao
on 9 Nov 2012
This may be of great interest to you! Someone has already done it.
Answers (2)
Walter Roberson
on 27 Jun 2012
Do not downscale the data: it must be full-range for the bitdepth (16). Use 'SignificantBits' of 12.
Grayscale, 16 bits per channel, 12 significant bits, is the way that PNG represents 12-bit grayscale images. Decoders are allowed to ignore the 12 bit specification
7 Comments
Anmol Sharma
on 24 Oct 2015
I have written a small utility to easily download, convert, view and get annotations from DDSM data, without the need for any manual work. You just need to download the required cases and then follow the instructions on how to use my utility to convert the LJPEG files to LJPEG1 and then to other formats like PNG, JPEG, TIF, GIF etc.
You can download my utility from here - https://github.com/trane293/DDSMUtility
The detailed instructions along with images are given in the Tutorial PDF file.
0 Comments
See Also
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!