uint16 累加_写一个uint16图像

How can I write an image of datatype uint16 to a file in MATLAB? I try to write to the file using the following command, but it gives me an error

imwrite(pimg, 'h44', 'jpg')

Error using writejpg>set_jpeg_props (line 183)

UINT16 image data requires bitdepth specifically set to

either 12 or 16.

Error in writejpg (line 49)

props = set_jpeg_props(data,varargin{:});

Error in imwrite (line 472)

feval(fmt_s.write, data, map, filename,

paramPairs{:});

Error in image16bit (line 666)

imwrite(imgnew1,'h44','jpg' );

解决方案

You must specify the BitDepth option when saving JPEG images with more than 8-bits:

% note that 16-bit only accepts grayscale images

img = imread('peppers.png');

imwrite(im2uint16(img), '12bit.jpg', 'BitDepth',12);

imwrite(rgb2gray(im2uint16(img)), '16bit.jpg', 'BitDepth',16);

Unfortunately, not many programs have support for 12-bit/16-bit JPEG images, so you might not be able to open it externally. You could use the JPEG2000 format instead:

imwrite(im2uint16(img), 'out.jp2');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值