当我写图像时,它看起来是黑色的 [英] When I write the image it appears black

查看:85
本文介绍了当我写图像时,它看起来是黑色的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回grayscale图像的程序.但是,当我尝试写入图像时,它完全显示为black.这是为什么?如何写图像并获得预期的结果?

I have a program that returns a grayscale image. But, when I try to write the image, it appears totally black. Why is that? How can I write the image and get the expected result?

谢谢.

推荐答案

首先检查数据类型.您可以通过示例 double() uint16()等来强制转换数据类型.(检查类型转换的帮助). 这是一个示例,说明如何将值重新缩放为uint16(无符号整数)的强度范围,其中〜65k可能有不同的值.当然,强制转换会降低强度值的精度.

First check on the type of your data. You can cast the type of the data by example double() or uint16() etc. (Check the help for typecasting). Here is an example how you rescale your values to the intensity-range of uint16, unsigned integers with ~65k possible different values. The casting of course leads to less precision of the intensity values.

new_img(:,:) = uint16((new_img(:,:)./max(max(new_img(:,:),[],1)))*65536);

随后,您应该能够将数据写入文件中.

Afterwards you should be able to write the data to your file.

这篇关于当我写图像时,它看起来是黑色的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆