image
显示来自数组的图像
Syntax
描述
图片(
displays the data in arrayC
)C
作为图像。每个元素C
指定的颜色1像素的图像。的resulting image is anm
-经过-n
grid of pixels wherem
is the number of rows andn
is the number of columns inC
。的row and column indices of the elements determine the centers of the corresponding pixels.
图像('cdata',
将图像添加到当前轴上,而无需更换现有图。该语法是低级版本的C
)图像(C)
。有关更多信息,请参阅High-Level Versus Low-Level Version of Image。
图片(___,
specifies image properties using one or more name-value pair arguments. You can specify image properties with any of the input argument combinations in the previous syntaxes.姓名,Value
)
图片(
creates the image in the axes specified byax
,___)ax
instead of in the current axes (GCA
). The optionax
can precede any of the input argument combinations in the previous syntaxes.
例子
Display Image of Matrix Data
Create matrixC
。Display an image of the data inC
。Add a colorbar to the graph to show the current colormap.
C = [0 2 4 6;8 10 12 14;16 18 20 22];图像(c)配色栏
默认情况下,CDataMapping
property for the image is set to'direct'
soimage
解释值C
as indices into the colormap. For example, the bottom right pixel corresponding to the last element inC
, 22, uses the 22nd color of the colormap.
Scale the values to the full range of the current colormap by setting theCDataMapping
property to'scaled'
when creating the image.
图像(c,'CDataMapping','scaled') colorbar
或者,您可以使用imagesc
function to scale the values instead of using图像(c,'CDataMapping','scaled')
。例如,useimagsc(c)
。
Control Image Placement
将图像放置在5到8之间x- 轴,在3至6之间y-轴。
x = [5 8];y = [3 6];C = [0 2 4 6;8 10 12 14;16 18 20 22];图像(x,y,c)
请注意,与C(1,1)相对应的像素以(5,3)为中心。对应于C(3,4)的像素以(8,6)为中心。image
positions and orients the rest of the image between those two points.
显示3-D真实颜色阵列的图像
CreateC
作为真实颜色的3-D阵列。通过将数组的最后两页设置为零来使用红色。
C = zeros(3,3,3); C(:,:,1) = [.1 .2 .3; .4 .5 .6; .7 .8 .9]
c = c(:,:,1)= 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.8000 0.9000 C(:, :, :, :,2)= 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C(:, :, :,3)= 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0
Display an image of the data inC
。
图像(C)
Modify Image After Creation
绘制一条线,然后在行顶部创建图像。返回图像对象。
情节(1:3)保持onC = [1 2 3;4 5 6;7 8 9];im =图像(c);
Make the image semitransparent so that the line shows through the image.
im.alphadata = 0.5;
Read and Display JPEG Image File
Read a JPEG image file.
C = imread('ngc6543a.jpg');
imread
返回650 x600 x-3阵列,C
。
显示图像。
图像(C)
Add Image to Axes in 3-D View
创建一个表面图。然后,在表面下添加图像。image
在xy-plane.
z = 10 +峰;冲浪(z)握住on图片(Z,'CDataMapping','scaled')
Input Arguments
C
—Image color data
vector or matrix|RGB三胞胎的3-D阵列
Image color data, specified in one of these forms:
Vector or matrix — This format defines indexed image data. Each element of
C
defines a color for 1 pixel of the image. For example,C = [1 2 3;4 5 6;7 8 9];
。元素C
map to colors in the colormap of the associated axes. TheCDataMapping
property controls the mapping method.RGB三重态的3-D数组 - 此格式使用RGB三重态值定义了真实的颜色图像数据。每个RGB三重态定义了图像的1像素的颜色。RGB三重态是一个三元素向量,它指定了颜色的红色,绿色和蓝色组件的强度。3-D数组的第一页包含红色组件,第二页包含绿色组件,第三页包含蓝色组件。由于图像使用真实颜色代替colormap颜色,因此
CDataMapping
property has no effect.If
C
is of type双倍的
,然后是RGB三重态值[0 0 0]
corresponds to black and[1 1 1]
对应于白色。If
C
is an integer type, then the image uses the full range of data to determine the color. For example, ifC
is of typeUINT8
, then[0 0 0]
corresponds to black and[255 255 255]
对应于白色。IfCData
is of typeint8
, then[-128 -128 -128]
corresponds to black and[127 127 127]
对应于白色。If
C
is of typelogical
, then[0 0 0]
corresponds to black and[1 1 1]
对应于白色。
This illustration shows the relative dimensions ofC
对于两种颜色模型。
行为NaN
元素未定义。
使用低级版本的image
function instead, set theCData
属性作为名称值对。例如,图像('cdata',c)
。
Converting Between双倍的
and Integer Data Types
When you call theimage
function with a vector or 2-D matrix and use the defaultCDataMapping
价值,您必须在之间转换时将数据值偏移1双倍的
值and integer types. This offset is not necessary whenCDataMapping
被设定为'scaled'
。
例如,如果U8
contains indexed image data of typeUINT8
, you can convert it to type双倍的
using:
d = double(u8) + 1;
从类型转换索引图像数据双倍的
对于整数类型,减去1并使用圆形的
确保所有值都是整数。例如,如果D
contains indexed image data of type双倍的
, convert it toUINT8
using:
U8 = uint8(round(D - 1));
Converting Between Normalized双倍的
and Truecolor Values
将真实的颜色图像数据从整数类型转换为类型双倍的
, rescale the data. For example, ifRGB8
is true color image data of typeUINT8
, convert it to双倍的
using:
rgb = double(rgb8)/255;
从类型转换真颜色图像数据双倍的
to an integer type, rescale the data and use圆形的
确保所有值都是整数。例如,如果RGB
是类型的图像数据双倍的
, convert it toUINT8
using:
RGB8 = uint8(round(RGB*255));
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|UINT8
|UINT16
|UINT32
|uint64
|logical
x
—Placement along x-axis
[1 size(C,2)]
(默认)|two-element vector|scalar
Placement along thex-axis, specified in one of these forms:
两元素向量 - 使用第一个元素作为中心的位置
C(1,1)
第二个要素作为中心的位置C(m,n)
, 在哪里[m,n] =尺寸(c)
。IfC
is a 3-D array, thenm
andn
are the first two dimensions. Evenly distribute the centers of the remaining elements ofC
在这两个点之间。每个像素的宽度由表达式确定:
(x(2)-x(1))/(size(C,2)-1)
If
x(1)
>x(2)
,然后将图像翻转为左右。标量 - 中心
C(1,1)
at this location and each following element one unit apart.
使用低级版本的image
function instead, set theXData
属性作为名称值对。例如,图片('XData',x,'YData',y,'CData',C)
。
You cannot interactively pan or zoom outside the x-axis limits or y-axis limits of an image, unless the limits are already set outside the bounds of the image. If the limits are already outside the bounds, there is no such restriction. If other objects (such as a line) occupy the axes and extend beyond the bounds of the image, you can pan or zoom to the bounds of the other objects, but no further.
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|UINT8
|UINT16
|UINT32
|uint64
|logical
y
—沿Y轴放置
[1 size(C,1)]
(默认)|two-element vector|scalar
Placement alongy-axis, specified in one of these forms:
两元素向量 - 使用第一个元素作为中心的位置
C(1,1)
第二个要素作为中心的位置C(m,n)
, 在哪里[m,n] =尺寸(c)
。IfC
is a 3-D array, thenm
andn
are the first two dimensions. Evenly distribute the centers of the remaining elements ofC
在这两个点之间。的height of each pixel is determined by the expression:
(y(2)-y(1))/(size(c,1)-1)
If
y(1)
>y(2)
, then the image is flipped up-down.标量 - 中心
C(1,1)
at this location and each following element one unit apart.
使用低级版本的image
function instead, set theYDATA
属性作为名称值对。例如,图片('XData',x,'YData',y,'CData',C)
。
You cannot interactively pan or zoom outside the x-axis limits or y-axis limits of an image, unless the limits are already set outside the bounds of the image. If the limits are already outside the bounds, there is no such restriction. If other objects (such as a line) occupy the axes and extend beyond the bounds of the image, you can pan or zoom to the bounds of the other objects, but no further.
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|UINT8
|UINT16
|UINT32
|uint64
|logical
ax
—轴
object
轴
object
轴
目的。如果您不指定轴
object, thenimage
使用当前轴。
姓名-Value Arguments
Specify optional pairs of arguments asname1 = value1,...,namen = valuen
, 在哪里姓名
is the argument name andValue
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and enclose姓名
用引号。
例子:图片([1 2 3],'AlphaData',0.5)
displays a semitransparent image.
此处列出的属性是图像属性的子集。有关完整列表,请参阅图像属性。
CDataMapping
—颜色数据映射方法
'direct'
(默认)|'scaled'
颜色数据映射方法, specified as'direct'
or'scaled'
。利用this property to control the mapping of color data values inCData
into the colormap.CData
must be a vector or a matrix defining indexed colors. This property has no effect ifCData
is a 3-D array defining true colors.
的methods have these effects:
'direct'
- 将值解释为当前菌落中的索引。十进制部分的值固定在最近的下部整数上。If the values are of type
双倍的
orsingle
, then values of1
or less map to the first color in the colormap. Values equal to or greater than the length of the colormap map to the last color in the colormap.If the values are of type
UINT8
,UINT16
,UINT32
,uint64
,int8
,INT16
,INT32
, orINT64
, then values of0
or less map to the first color in the colormap. Values equal to or greater than the length of the colormap map to the last color in the colormap (or up to the range limits of the type).If the values are of type
logical
, then values of0
map to the first color in the colormap and values of1
在菌落中映射到第二种颜色。
'scaled'
— Scale the values to range between the minimum and maximum color limits. The攀登
property of the axes contains the color limits.
AlphaData
—Transparency data
1
(默认)|scalar|数组大小与CData
Transparency data, specified in one of these forms:
标量 - 在整个图像上使用一致的透明度。
Array the same size as
CData
- 为每个图像元素使用不同的透明度值。
的AlphaDataMapping
property controls how MATLAB®interprets the alpha data transparency values.
例子:0.5
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|UINT8
|UINT16
|UINT32
|uint64
|logical
AlphaDataMapping
—解释AlphaData
值
'none'
(默认)|'scaled'
|'direct'
解释AlphaData
值, specified as one of these values:
'none'
— Interpret the values as transparency values. A value of 1 or greater is completely opaque, a value of 0 or less is completely transparent, and a value between 0 and 1 is semitransparent.'scaled'
- 将值映射到图的alphamap中。轴的最小和最大α极限决定了分别映射到Alphamap中第一个和最后一个元素的alpha数据值。例如,如果alpha限制为[3 5]
, then alpha data values less than or equal to3
映射到alphamap中的第一个元素。alpha数据值大于或等于5
alphamap映射到最后一个元素。的阿里姆
轴的属性包含alpha限制。的Alphamap
图的属性包含alphamap。'direct'
— Interpret the values as indices into the figure’s alphamap. Values with a decimal portion are fixed to the nearest lower integer:If the values are of type
双倍的
orsingle
, then values of 1 or less map to the first element in the alphamap. Values equal to or greater than the length of the alphamap map to the last element in the alphamap.If the values are of type integer, then values of 0 or less map to the first element in the alphamap. Values equal to or greater than the length of the alphamap map to the last element in the alphamap (or up to the range limits of the type). The integer types are
UINT8
,UINT16
,UINT32
,uint64
,int8
,INT16
,INT32
, andINT64
。If the values are of type
logical
, then values of 0 map to the first element in the alphamap and values of 1 map to the second element in the alphamap.
输出参数
im
—Image
object
Image
object
Image
对象,返回为标量。利用im
创建图像后设置属性。对于列表,请参阅图像属性。
More About
High-Level Versus Low-Level Version of Image
的image
function has two versions, the high-level version and the low-level version. If you useimage
with'cdata'
作为输入参数,您正在使用低级版本。否则,您正在使用高级版本。
高级版本的image
callsnewplot
before plotting and sets these axes properties:
的low-level version of theimage
function does not callnewplot
and does not set these axes properties.
提示
扩展功能
GPU数组
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
用法注释和限制:
This function accepts GPU arrays, but does not run on a GPU.
有关更多信息,请参阅Run MATLAB Functions on a GPU(并行计算工具箱)。
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
用法注释和限制:
This function operates on distributed arrays, but executes in the client MATLAB.
有关更多信息,请参阅Run MATLAB Functions with Distributed Arrays(并行计算工具箱)。
Version History
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
You can also select a web site from the following list:
如何获得最佳网站性能
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(英语)
- United States(英语)