转载自https://www.mathworks.com/help/matlab/creating_plots/image-types.html

Image Types

Indexed Images

An indexed image consists of a data matrix, X, and a colormap matrix, mapmap is an m-by-3 array of class double containing floating-point values in the range [0, 1]. Each row of map specifies the red, green, and blue components of a single color. An indexed image uses “direct mapping” of pixel values to colormap values. The color of each image pixel is determined by using the corresponding value of X as an index into map. Values of X therefore must be integers. The value 1 points to the first row in map, the value 2 points to the second row, and so on. Display an indexed image with the statements

image(X); colormap(map)

A colormap is often stored with an indexed image and is automatically loaded with the image when you use the imread function. However, you are not limited to using the default colormap—use any colormap that you choose. The description for the property CDataMapping describes how to alter the type of mapping used.

The next figure illustrates the structure of an indexed image. The pixels in the image are represented by integers, which are pointers (indices) to color values stored in the colormap.

The relationship between the values in the image matrix and the colormap depends on the class of the image matrix. If the image matrix is of class double, the value 1 points to the first row in the colormap, the value 2 points to the second row, and so on. If the image matrix is of class uint8 or uint16, there is an offset—the value 0 points to the first row in the colormap, the value 1 points to the second row, and so on. The offset is also used in graphics file formats to maximize the number of colors that can be supported. In the preceding image, the image matrix is of class double. Because there is no offset, the value 5 points to the fifth row of the colormap.

Grayscale (Intensity) Images

A grayscale image, sometimes referred to as an intensity image, is a data matrix I whose values represent intensities within some range. A grayscale image is represented as a single matrix, with each element of the matrix corresponding to one image pixel. The matrix can be of class doubleuint8, or uint16. While grayscale images are rarely saved with a colormap, a colormap is still used to display them. In essence, grayscale images are treated as indexed images.

This figure depicts a grayscale image of class double.

To display a grayscale image, use the imagesc (“image scale”) function, which enables you to set the range of intensity values. imagesc scales the image data to use the full colormap. Use the two-input form of imagesc to display a grayscale image, for example:

imagesc(I,[0 1]); colormap(gray);

The second input argument to imagesc specifies the desired intensity range. The imagesc function displays I by mapping the first value in the range (usually 0) to the first colormap entry, and the second value (usually 1) to the last colormap entry. Values in between are linearly distributed throughout the remaining colormap colors.

Although it is conventional to display grayscale images using a grayscale colormap, it is possible to use other colormaps. For example, the following statements display the grayscale image I in shades of blue and green:

imagesc(I,[0 1]); colormap(winter);

To display a matrix A with an arbitrary range of values as a grayscale image, use the single-argument form of imagesc. With one input argument, imagesc maps the minimum value of the data matrix to the first colormap entry, and maps the maximum value to the last colormap entry. For example, these two lines are equivalent:

imagesc(A); colormap(gray)
imagesc(A,[min(A(:)) max(A(:))]); colormap(gray)

RGB (Truecolor) Images

An RGB image, sometimes referred to as a truecolor image, is stored as an m-by-n-by-3 data array that defines red, green, and blue color components for each individual pixel. RGB images do not use a palette. The color of each pixel is determined by the combination of the red, green, and blue intensities stored in each color plane at the pixel's location. Graphics file formats store RGB images as 24-bit images, where the red, green, and blue components are 8 bits each. This yields a potential of 16 million colors. The precision with which a real-life image can be replicated has led to the nickname “truecolor image.”

An RGB MATLAB array can be of class doubleuint8, or uint16. In an RGB array of class double, each color component is a value between 0 and 1. A pixel whose color components are (0,0,0) is displayed as black, and a pixel whose color components are (1,1,1) is displayed as white. The three color components for each pixel are stored along the third dimension of the data array. For example, the red, green, and blue color components of the pixel (10,5) are stored in RGB(10,5,1)RGB(10,5,2), and RGB(10,5,3), respectively.

To display the truecolor image RGB, use the image function:

image(RGB)

The next figure shows an RGB image of class double.

To determine the color of the pixel at (2,3), look at the RGB triplet stored in (2,3,1:3). Suppose (2,3,1) contains the value 0.5176, (2,3,2) contains 0.1608, and (2,3,3) contains 0.0627. The color for the pixel at (2,3) is

0.5176 0.1608 0.0627

[转载] Image Types的更多相关文章

  1. Non-Nullable Types vs C#: Fixing the Billion Dollar Mistake (转载)

    One of the top suggestions (currently #15 on uservoice) for improving C# is the addition of non-null ...

  2. RTP与RTCP协议介绍(转载)

    RTSP发起/终结流媒体.RTP传输流媒体数据 .RTCP对RTP进行控制,同步.RTP中没有连接的概念,本身并不能为按序传输数据包提供可靠的保证,也不提供流量控制和拥塞控制,这些都由RTCP来负责完 ...

  3. 转载:《TypeScript 中文入门教程》 13、类型兼容性

    版权 文章转载自:https://github.com/zhongsp 建议您直接跳转到上面的网址查看最新版本. 介绍 TypeScript里的类型兼容性基于结构子类型的. 结构类型是只一种只使用其成 ...

  4. RS-232, RS-422, RS-485 Serial Communication General Concepts(转载)

    前面转载的几篇文章重点介绍了UART及RS-232.在工控领域除了RS-232以外,常用的串行通信还有RS-485.本文转载的文章重点介绍了RS-232.RS-422和RS-485. Overview ...

  5. C#反射机制 (转载)

    转载:原文出处      http://www.cnblogs.com/binfire/archive/2013/01/17/2864887.html 一:反射的定义 审查元数据并收集关于它的类型信息 ...

  6. [转载]config文件的一个很好的实现

    以下是转载于网上的一个很好的config文件的实现,留存以备案 //Config.h #pragma once #include <string> #include <map> ...

  7. JAVA泛型详解2 转载

    转载地址:http://www.cnblogs.com/sunwei2012/archive/2010/10/08/1845938.html 普通泛型 class Point<T>{ // ...

  8. JDBC 内部资料 请勿转载 谢谢合作

    一.JDBC常用接口.类介绍 JDBC提供对独立于数据库统一的API,用以执行SQL命令.API常用的类.接口如下: DriverManager 管理JDBC驱动的服务类,主要通过它获取Connect ...

  9. python "yield"(转载)

    转载地址:http://www.ibm.com/developerworks/cn/opensource/os-cn-python-yield/ 您可能听说过,带有 yield 的函数在 Python ...

  10. [转载]Context and Interception : The .NET Context

    转载自:Context and Interception : The .NET Context Every new app domain starts with a single context, c ...

随机推荐

  1. CF1367E Necklace Assembly

    题目传送门 思路 提供一种比现有的两篇题解都简单的方法. 我们枚举答案,发现最终的答案数组一定是由多个完全相同的块组成的,并且块长必定是 \(k\) 的因数. 然后我们考虑枚举答案 \(i\),那么此 ...

  2. PHP的25种框架

    本篇文章给大家分享的内容是25种PHP框架 -有着一定的参考价值,有需要的朋友可以参考一下. 世界流行框架汇总 在项目开发中,一些架构和代码都是重复的,为了避免重复劳动,于是各种各样的框架诞生了. 在 ...

  3. 9.【go-kit教程】go-kit集成Prometheus

    在 Go kit 中集成 Prometheus 进行 API 监控可以帮助开发人员更好地了解系统的性能和行为,提高系统的可观察性和可靠性.下面是一个简单的示例,演示如何在 Go kit 中集成 Pro ...

  4. vue-fullpage全屏插件使用

    直入主题:vue项目中想做一个全屏翻滚的效果,vue-fullpage 就很不错 下面介绍vue-fullpage 的使用方法,这里封装成了vue的一个指令的形式来进行使用 1.安装vue-fullp ...

  5. .Net DI(Dependency Injection)依赖注入机制

    1.简介 DI:Dependency Injection,即依赖注入,他是IOC的具体实现. 在DI中,底层服务对象不再负责依赖关系的创建,而是交由顶端调用进行管理注入 好处:降低组件之间的耦合度,使 ...

  6. Anaconda 使用教程

    Anaconda介绍 Anaconda指的是一个开源的Python发行版本,其包含了conda.Python等180多个科学包及其依赖项. 因为包含了大量的科学包,Anaconda 的下载文件比较大( ...

  7. PHP解密支付宝小程序的加密数据,手机号等。

    1.小程序端代码示例 my.getPhoneNumber({ success: (res) => { let encryptedData = res.response; my.httpReque ...

  8. Prometheus监控操作

    一.架构说明 ➢ Prometheus Server:Prometheus 生态最重要的组件,主要用于抓取和存储时间序列数据, 同时提供数据的查询和告警策略的配置管理: ➢  Alertmanager ...

  9. SQL SERVER提示pre-login handshake failed错误的一种解决方法。

    昨天在客户那里,遇到一个奇怪的问题.程序直接运行的时候,可以正常连接SQL SERVER; 但是使用Web Service连接SQL SERVER的时候,出现了下面的错误信息: Connection ...

  10. 如何写出不可维护的Vue代码

    前言 不止一次接手过复杂业务功能模块,开端总是深陷其中难以自拔,无数个深夜抚摸着头皮在内心暗暗咒骂. 相信你也有过类似的经历,面对复杂的业务逻辑,看代码俩小时,写代码五分钟,没有点胆识和谋略都不敢下手 ...