matlab中imwrite函数详解(imwrite的输出格式)
参考资料:
https://www.mathworks.com/help/matlab/ref/imwrite.html?s_tid=srchtitle
你可能觉得imread函数很简单,但是还是有一些细节要注意。比如我就对imwrite函数输出的图片格式有一些疑问,下面对imwrite函数的用法进行解释,先放一下官方文档:
imwrite( writes image data A,filename)A to the file specified by filename, inferring the file format from the extension. imwrite creates the new file in your current folder. The bit depth of the output image depends on the data type of A and the file format. For most formats:
If
Ais of data typeuint8, thenimwriteoutputs 8-bit values.If
Ais of data typeuint16and the output file format supports 16-bit data (JPEG, PNG, and TIFF), thenimwriteoutputs 16-bit values. If the output file format does not support 16-bit data, thenimwritereturns an error.If
Ais a grayscale or RGB color image of data typedoubleorsingle, thenimwriteassumes that the dynamic range is [0,1] and automatically scales the data by 255 before writing it to the file as 8-bit values. If the data inAissingle, convertAtodoublebefore writing to a GIF or TIFF file.If
Ais of data typelogical, thenimwriteassumes that the data is a binary image and writes it to the file with a bit depth of 1, if the format allows it. BMP, PNG, or TIFF formats accept binary images as input arrays.
If A contains indexed image data, you should additionally specify the map input argument.
imwrite的用法本身也很简单,A是一个图像矩阵,从上述说明中可以看出,A的数据类型可以是uint8,uint16,logical等,还可以是indexed image data即索引图。filename是一个字符串,将输出图像的路径和文件名传给filename即可。更进一步从描述中可看出,输出图片文件的格式由后缀名(extension)决定,uint8基本都支持,uint16则仅有部分图片格式支持。此时我们就要specific文件名的后缀,防止出现error。
看文档又好奇这个indexed image即索引图是什么,在网上找了一张图:

简单来说就是给一幅图像出现的所有RGB值编一个映射表,然后有一个和图像形状一样的索引矩阵,查表即可得到RGB图。
matlab中imwrite函数详解(imwrite的输出格式)的更多相关文章
- JavaScript正则表达式详解(二)JavaScript中正则表达式函数详解
二.JavaScript中正则表达式函数详解(exec, test, match, replace, search, split) 1.使用正则表达式的方法去匹配查找字符串 1.1. exec方法详解 ...
- 【转】linux 中fork()函数详解
在看多线程的时候看到了这个函数,于是学习了下,下面文章写的通俗易懂,于是就开心的看完了,最后还是很愉快的算出了他最后一个问题. linux 中fork()函数详解 一.fork入门知识 一个进程,包括 ...
- Linux中fork()函数详解(转载)
linux中fork()函数详解 一.fork入门知识 一个进程,包括代码.数据和分配给进程的资源.fork()函数通过系统调用创建一个与原来进程几乎完全相同的进程,也就是两个进程可以做完全相同的事, ...
- C++中重载函数详解
函数的重载详解 什么时函数重载: 函数重载是指在同一作用域内,可以有一组具有相同函数名,不同参数列表的函数,这组函数被称为重载函数.重载函数通常用来命名一组功能相似的函数,这样做减少了函数名的数量,避 ...
- php中magic_quotes_gpc函数详解
magic_quotes_gpc函数在php中的作用是判断解析用户提示的数据,如包括有:post.get.cookie过来的数据增加转义字符“\”,以确保这些数据不会引起程序,特别是数据库语句因为特殊 ...
- python unittest框架中addCleanup函数详解
接上一篇doCleanups说明,这次介绍下另一个很好用的函数:addCleanup 还是老规矩,看官方文档说明: addCleanup(function, *args, **kwargs)¶ Add ...
- JavaScript基础内容中的函数详解
函数 函数:即方法 函数就是一段预先设置的功能代码块,可以反复调用,根据输入参数的不同,返回不同的值. 为什么使用函数: 1.方便调用 2.代码重用,利于维护 3.便于修改,便于重构 4.简化逻辑,利 ...
- python中groupby函数详解(非常容易懂)
一.groupby 能做什么? python中groupby函数主要的作用是进行数据的分组以及分组后地组内运算! 对于数据的分组和分组运算主要是指groupby函数的应用,具体函数的规则如下: df[ ...
- matlab的pdist函数详解
Pairwise distance between pairs of object(Pdist函数用于各种距离的生成) 语法: D=pdist(x) D=pdist(x,distance) 解释: D ...
随机推荐
- 一言难尽,Jpa这个功能差点让我丢了工作
故事背景 前阵子,有位朋友在微信上问我数据被删了能不能恢复,我问了下原因,居然是因为一个配置项惹的祸. 故事细节 在 Spring Boot 中使用 jpa 来操作数据库,jpa 就不做详细的介绍了, ...
- SVN强制添加备注
1.进入仓库project1/hooks目录,找到pre-commit.tmpl文件 cp pre-commit.tmpl pre-commit 2.编辑pre-commit文件, 将: $SVNLO ...
- JAVA局部变量和成员变量的区别
成员变量与局部变量的区别 1.在类中的位置不同 成员变量:在类中方法外面 局部变量:在方法或者代码块中,或者方法的声明上(即在参数列表中) 2.在内存中的位置不同 成员变量:在堆中(方法区中的静态区) ...
- jmeter之cookies管理器的使用
作用: 1 发送请求,经常要校验cookies信息 2 针对有的cookie是用的sessionid来进行校验的,这个就需要自己去配置cookie管理器里面的信息,而且sessionid是有时效性的 ...
- Docker的iptables规则在iptables重启后丢失
前因后果 1.在跳板机上使用ansible命令测试机器B时,报错如下,于是就怀疑是网络防火墙的问题 10.10.0.86 | FAILED >> { "failed": ...
- mysql页面查询
<?php $link = mysql_connect('127.0.0.1', 'root', 'root'); if (!$link) { die('Could not connect: ' ...
- 解决google play上架App设置隐私政策声明问题
在我们的app上架到google play后,为了赚点小钱,就集成google ads,然而这会引发一个新的问题,那就是设置隐私政策声明的问题,通常我们会收到一封来自google play的邮件,提示 ...
- Rocket - 断句 - Diplomacy and TileLink from the Rocket Chip
https://mp.weixin.qq.com/s/rfgptF9YxDpzDoespYtQvA 整理Diplomacy and TileLink from the Rocket Chip这篇文 ...
- Java 蓝桥杯 算法训练(VIP) 最大体积
最大体积 问题描述 每个物品有一定的体积(废话),不同的物品组合,装入背包会战用一定的总体积. 假如每个物品有无限件可用,那么有些体积是永远也装不出来的. 为了尽量装满背包,附中的OIER想要研究一下 ...
- Java实现 LeetCode 80 删除排序数组中的重复项 II(二)
80. 删除排序数组中的重复项 II 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素最多出现两次,返回移除后数组的新长度. 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O ...