参考资料:

  https://www.mathworks.com/help/matlab/ref/imwrite.html?s_tid=srchtitle

  你可能觉得imread函数很简单,但是还是有一些细节要注意。比如我就对imwrite函数输出的图片格式有一些疑问,下面对imwrite函数的用法进行解释,先放一下官方文档:


imwrite(A,filename) writes image data 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 A is of data type uint8, then imwrite outputs 8-bit values.

  • If A is of data type uint16 and the output file format supports 16-bit data (JPEG, PNG, and TIFF), then imwrite outputs 16-bit values. If the output file format does not support 16-bit data, then imwrite returns an error.

  • If A is a grayscale or RGB color image of data type double or single, then imwrite assumes 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 in A is single, convert A to double before writing to a GIF or TIFF file.

  • If A is of data type logical, then imwrite assumes 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的输出格式)的更多相关文章

  1. JavaScript正则表达式详解(二)JavaScript中正则表达式函数详解

    二.JavaScript中正则表达式函数详解(exec, test, match, replace, search, split) 1.使用正则表达式的方法去匹配查找字符串 1.1. exec方法详解 ...

  2. 【转】linux 中fork()函数详解

    在看多线程的时候看到了这个函数,于是学习了下,下面文章写的通俗易懂,于是就开心的看完了,最后还是很愉快的算出了他最后一个问题. linux 中fork()函数详解 一.fork入门知识 一个进程,包括 ...

  3. Linux中fork()函数详解(转载)

    linux中fork()函数详解 一.fork入门知识 一个进程,包括代码.数据和分配给进程的资源.fork()函数通过系统调用创建一个与原来进程几乎完全相同的进程,也就是两个进程可以做完全相同的事, ...

  4. C++中重载函数详解

    函数的重载详解 什么时函数重载: 函数重载是指在同一作用域内,可以有一组具有相同函数名,不同参数列表的函数,这组函数被称为重载函数.重载函数通常用来命名一组功能相似的函数,这样做减少了函数名的数量,避 ...

  5. php中magic_quotes_gpc函数详解

    magic_quotes_gpc函数在php中的作用是判断解析用户提示的数据,如包括有:post.get.cookie过来的数据增加转义字符“\”,以确保这些数据不会引起程序,特别是数据库语句因为特殊 ...

  6. python unittest框架中addCleanup函数详解

    接上一篇doCleanups说明,这次介绍下另一个很好用的函数:addCleanup 还是老规矩,看官方文档说明: addCleanup(function, *args, **kwargs)¶ Add ...

  7. JavaScript基础内容中的函数详解

    函数 函数:即方法 函数就是一段预先设置的功能代码块,可以反复调用,根据输入参数的不同,返回不同的值. 为什么使用函数: 1.方便调用 2.代码重用,利于维护 3.便于修改,便于重构 4.简化逻辑,利 ...

  8. python中groupby函数详解(非常容易懂)

    一.groupby 能做什么? python中groupby函数主要的作用是进行数据的分组以及分组后地组内运算! 对于数据的分组和分组运算主要是指groupby函数的应用,具体函数的规则如下: df[ ...

  9. matlab的pdist函数详解

    Pairwise distance between pairs of object(Pdist函数用于各种距离的生成) 语法: D=pdist(x) D=pdist(x,distance) 解释: D ...

随机推荐

  1. 第3章 衡量线性回归的指标:MSE,RMSE,MAE

    , , ,, , ,  , 

  2. [注]一条牛B的游戏推送要具备哪些条件?

    旁白:推送内容写的好,可以给游戏带来很大的收益,但如果写的很糟糕,就可能是在提醒用户还有一个该卸载的软件没卸载.那么如何写出一个优秀的推送内容呢? 总结:推送文字八字原则 从运营的角度来讲,我们需要找 ...

  3. CELF算法原理

    影响力传播模型中的独立层叠模型(independent cascading model,IC模型),影响力传播过程中,种子的影响力具备子模性(submodularity),即种子的边际影响力增量会呈现 ...

  4. 前端基础知识之html和css全解

    前端回顾 目录 前端回顾 基础知识 HTTP协议 认识HTML HTML组成 HTML标签 div和span标签 特殊的属性 常用标签 认识css 选择器 属性 前端就是展示给用户并且与用户进行交互的 ...

  5. MySQL8离线安装

    现在离线安装包: 登录官网准备下载 https://dev.mysql.com/downloads/mysql/ 2,开始下载 解压安装包: 开始解压: 解压完成: 新建init文件: 在解压目录下创 ...

  6. conda虚拟环境安装

    一.背景 需要学习mxnet,建一个conda虚拟软件环境. 二.步骤 1.下载anaconda安装文件:https://mirrors.tuna.tsinghua.edu.cn/anaconda/m ...

  7. 关于ueditor编译器

    取消自动保存提示.edui-editor-messageholder.edui-default{ visibility:hidden;} Qiyuwen 1033935470@qq.com

  8. jchdl - RTL Data Types

    https://mp.weixin.qq.com/s/hWYW1Bn---WhpwVu2e98qA   一. Bit ​​ 类结构如下: ​​   主要属性: value: bit的值,只支持0,1, ...

  9. Take advantage of Checkra1n to Jailbreak iDevice for App analysis

    An unpatchable bootrom exploit called "checkm8" works on all iDevices up until the iPhone ...

  10. Java实现 LeetCode 355 设计推特

    355. 设计推特 设计一个简化版的推特(Twitter),可以让用户实现发送推文,关注/取消关注其他用户,能够看见关注人(包括自己)的最近十条推文.你的设计需要支持以下的几个功能: postTwee ...