BMP to grayscale image?
12 ビュー (過去 30 日間)
古いコメントを表示
Hello Sir!
I am writing a gray scale image using: imwrite(gray,'exp.bmp') I want the exact gray scale image back from the bmp image. How can i do this?
or please tel me how can I export a gray scale matrix as image and get it back losslessly?
0 件のコメント
採用された回答
Walter Roberson
2011 年 1 月 22 日
If your gray scale matrix is uint8 data class, that is what will happen automatically for BMP files.
If your gray scale matrix is double precision data in the range 0 to 1, then what you want to do cannot be done with BMP files. BMP files are restricted to 1 bit per pixel, 8 bits per pixel, or 24 bits deep (i.e., 3 components each 8 bits per pixel). Double precision gray scale images will be scaled by a factor of 255 and the 8 bits of the integer part of the result will be stored. This will lose precision unless all of your data happens to be integer multiples of 1/256 .
The PNG file format can support 16 bit grayscale images, which refines the precision to integer multiples of 1/65536
If you use the PPM file format, then you might be able to use 'Encoding', 'ASCII', 'MaxValue', 2^53 . That would get you access to the full double precision mantissa bits, but if you had gray values less than 1/2^53 then you would lose those values even though they are easily representable in double-precision numbers.
At least as of 2008b, there is no image file format documented as being able to handle full 64 bit double precision gray scale images, so if that is the kind of data you have, either you have to accept some loss, or you have to store the data in the file in such a way that although the file holds all of the data, the image you see would not be viewable without special software.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!