当前位置:网站首页>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
边栏推荐
- JVM garbage collector details
- 用OpenPose进行单个或多个人体姿态估计
- Scala110-combineByKey
- UIDocumentInteractionController UIDocumentPickerViewController
- The implementation process of inheritance and the difference between Es5 and ES6 implementation
- Outline and box shadow to achieve the highlight effect of contour fillet
- Run redis on docker to start in the form of configuration file, and the connection client reports an error: server closed the connection
- SVD奇异值分解推导及应用与信号恢复
- Spark AQE
- What is the Internet of things
猜你喜欢

如何解决Visual Studio中scanf编译报错的问题

记一次Yarn Required executor memeory is above the max threshold(8192MB) of this cluster!

spark分区算子partitionBy、coalesce、repartition

ML - 语音 - 传统语音模型

ML - 图像 - 深度学习和卷积神经网络

Yan required executor memory is above the max threshold (8192mb) of this cluster!

MATLAB 如何生产随机复序列

Spark提交参数--files的使用

Introduction to raspberry Pie: initial settings of raspberry pie

什么是物联网
随机推荐
pkg_ Resources dynamic loading plug-in
Promise object and macro task, micro task
MySql的安装配置超详细教程与简单的建库建表方法
Scala111-map、flatten、flatMap
ML - 自然语言处理 - 基础知识
Recommend 10 learning websites that can be called artifact
Image cropper example
Scala111-map、flatten、flatMap
ML - natural language processing - Key Technologies
Xcode添加mobileprovision证书文件报错:Xcode encountered an error
推荐10个堪称神器的学习网站
C language function review (pass value and address [binary search], recursion [factorial, Hanoi Tower, etc.))
海缆探测仪TSS350(一)
Overview of JS synchronous, asynchronous, macro task and micro task
MySQL transactions and mvcc
如何更新更新数据库中的json值?
Endnote 添加中文GBT7714样式 word中如何引用文献
Solve the timeout of dbeaver SQL client connection Phoenix query
Remember that spark foreachpartition once led to oom
Instance Tunnel 使用