当前位置:网站首页>MATLAB读取显示图像时数据格式转换原因
MATLAB读取显示图像时数据格式转换原因
2022-07-25 15:22:00 【町棠棠】
matlab读入图像的数据是uint8,而matlab中数值一般采用double型(64位)运算。
double的数据是有小数点的,而uint8是0-255的整数,如果直接用uint8计算,会在计算过程中产生舍入误差,这种误差在图像的数据中是比较大的误差。
uint8的操作仅仅是将一个double类型的小数点后面的部分去掉;
参考:https://www.pianshen.com/article/1006326703/
1、MATLAB在读取图像时要将图片数据转换为double

imread() 把灰度图存入一个8位矩阵或彩图存入8位RGB矩阵中
因为MATLAB读入图像的数据是uint8格式,但是MATLAB中一般采用double型(64)位进行和运算,所以要把图像转为double型。
2、MATLAB图像显示时要用uint8格式

imshow()显示图像时,需要用uint8格式,即要把double格式转为uint8
3、总结

MATLAB为了节省存储空间,所以在一开始读入图像是uint8的格式,即8位存储。
但是在MATLAB中参与运算是要double型,所以此时需转换图片数据格式double。
显示图片时,如果直接imshow(double数据格式),那么只会是白色图片,因为
这是因为imshow()显示图像时对double型是认为在0~1范围内,即大于1时都是显示为白色,而imshow显示uint8型时是0~255范围。所以要将在显示时转换数据为uint8
参考链接:
https://blog.csdn.net/qq_26093511/article/details/53785298
边栏推荐
- Tasks, micro tasks, queues and scheduling (animation shows each step of the call)
- Idea远程提交spark任务到yarn集群
- Spark SQL UDF function
- 了解一下new的过程发生了什么
- How to update JSON values in the database?
- 用setTimeout模拟setInterval定时器
- Remember that spark foreachpartition once led to oom
- Es5 thinking of writing inheritance
- Scala110-combineByKey
- Image cropper example
猜你喜欢

《三子棋》C语言数组应用 --n皇后问题雏形

Example of password strength verification

ML - 语音 - 语音处理介绍

Solve the timeout of dbeaver SQL client connection Phoenix query

Run redis on docker to start in the form of configuration file, and the connection client reports an error: server closed the connection

Spark partition operators partitionby, coalesce, repartition

延迟加载源码剖析:

Application of object detection based on OpenCV and yolov3

Outline and box shadow to achieve the highlight effect of contour fillet

ML - 语音 - 深度神经网络模型
随机推荐
How spark gets columns in dataframe --column, $, column, apply
什么是物联网
CGO is realy Cool!
Rediscluster setup and capacity expansion
Tasks, micro tasks, queues and scheduling (animation shows each step of the call)
RedisCluster搭建和扩容
Spark 内存管理机制 新版
ML - 语音 - 高级语音模型
Spark submission parameters -- use of files
Spark SQL null value, Nan judgment and processing
Debounce and throttle
ML - Speech - advanced speech model
What is the Internet of things
Spark memory management mechanism new version
Idea远程提交spark任务到yarn集群
MySQL installation and configuration super detailed tutorial and simple database and table building method
Endnote 添加中文GBT7714样式 word中如何引用文献
Single or multiple human posture estimation using openpose
Spark judges that DF is empty
The development summary of the function of fast playback of audio and video in any format on the web page.