how to save an image without using 'uint8'?

i want to save my image with its actual pixel value which is float/double. i am using 'png' format picture & _ 'imwrite(uint8(image));'_ to save it. now i want it without 'uint8'

답변 (1개)

Guillaume
Guillaume 2015년 9월 17일

1 개 추천

The png format only supports integer pixels (up to 16 bits). There are actually very few mainstream image formats that support floating point pixels as for visualisation the decimal part makes no difference.
In theory, you could save the image as png (converting it to integer) while storing the original image in a custom png chunk, but matlab does not give that level of control over load/save of png images.
I'm sure we've told you this before: if you want to save the image for visualisation, convert it to integer, you can use uint16 instead of uint8 for more precision. If you want to save the image for further precision save it as mat file. If you want to do both, save it in both formats.

댓글 수: 7

i must have to save the image for both visualization & for work further which better not to be converted in integer format. i am not allowed to use mat file at any cost. suggest image formats that support floating point pixels
Guillaume
Guillaume 2015년 9월 17일
Have a look at the format table in the documentation of imwrite and the description of each format. None of them with maybe the exception of tiff support floating point values.
Possibly, you could save floating points values in tiff with the help of the Tiff class. There's no guarantee that your image viewer will be able to view the tiff image though. There are so many variants of tiff that not all of them are supported by all programs.
There are some niche image formats that do support floating point pixels (e.g. FITS files) but you're going to struggle to find a compatible image viewer.
Are you still trying to hide a watermark in floating point? As I indicated before, you can use TIFF for floating point images but the moment anyone converts the file to most other image file format the floating point is going to be lost.
I see that Radiance and OpenEXR image file formats support 16 and 32 bit float. DICOM supports floating point. Some other image file formats that support floating point are listed at http://www.spherevfx.com/written-training/miscellaneous-written-training/file-formats-channels-and-colour-depth/ including Adobe Photoshop Layered (PSD)
If you are willing to confine your hiding to those then you might get somewhere, but otherwise No.
According to Jeff Mather, leader of the Image Processing team at the Mathworks, dicom (at least Mathworks implementation of it from 10 years ago) does not support floating point variables. So I guess you should use .mat files.
Guillaume
Guillaume 2015년 9월 17일
To summarise, mainstream (PNG, JPEG, BMP, TIF, ...) image formats do not support floating point pixels (that's not what they're designed for), so if you want that you'll have to use exotic or proprietary image formats that are not widely supported outside of their field of use.
This would be a strong indication that you need to revise your requirements. Give up the need to save as a standard image format, give up the need for floating point, or give up saving it all in one file.
TIF does support floating point, and you can create floating point TIF images using the Tiff class in MATLAB.
I was mistaken about DICOM support for images (though you can insert such data under a private Bulk Data tag.)
Guillaume
Guillaume 2015년 9월 17일
Yes, tif support floating point. Whether your image editor/viewer will cope with such image is not guaranteed.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 DICOM Format에 대해 자세히 알아보기

질문:

2015년 9월 17일

댓글:

2015년 9월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by