参考资料:

  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. docker常用命令,及进入Tomcat的WebApps发布目录(就是进入docker容器后台目录)

    docker常用命令,及进入Tomcat的WebApps发布目录(就是进入docker容器后台目录)   一.常用命令 1.显示所有的容器,包括未运行的 docker ps -a   2.启动容器.注 ...

  2. 【python 爬虫】fake-useragent Maximum amount of retries reached解决方案

    前言 在用fake-useragent的时候发生报错,fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reach ...

  3. PIC单片机的for定时

    看到公司的一个项目上的用的for定时 但是网上查找看到<PIC16系列单片机C程序设计与PROTEUS仿真> 上有关于for语句的定时 void Delay(unsigned int n) ...

  4. 【asp.net core 系列】 1 带你了解一下asp.net core

    0. 前言 这是一个新的系列,名字是<ASP.NET Core 入门到实战>.这个系列主讲ASP.NET Core MVC,辅助一些前端的基础知识(能用来实现我们需要的即可,并非主讲).同 ...

  5. JavaScript ——内部函数和匿名函数

    在JS中,函数是一种数据类型,可以将它赋值给变量,因此函数可以这样创建: var func=function(){ alert("func"); } func(); 既然函数是一种 ...

  6. 50个SQL语句(MySQL版) 问题三

    --------------------------表结构-------------------------- student(StuId,StuName,StuAge,StuSex) 学生表 tea ...

  7. 【极客思考】计算机网络:Wireshark抓包分析TCP中的三次握手与四次挥手

    [摘要]本文重点分析计算机网络中TCP协议中的握手和挥手的过程. [前提说明] 前段时间突然看到了一篇关于TCP/IP模型的文章,心想这段时间在家里也用wireshark抓了点包,那么想着想着就觉得需 ...

  8. jchdl - GSL实例 - Add

    https://mp.weixin.qq.com/s/6xcYYdYZTBPTf25xFluzBQ   使用FullAdder级联实现加法器   参考链接: https://github.com/wj ...

  9. 【zookeeper】安装教程文档需下载

    请查看文件https://download.csdn.net/download/qq_42158942/11846847 zookeeper的作用 • ZooKeeper 是一个开源的分布式协调服务, ...

  10. JS遍历对象修改属性名

    根据接口返回数据中number属性值,对数据进行截取,并改变属性名.直接上码: 下面是需要处理的数据 let data={"minValue":7400, "maxVal ...