Main Content

Crosshair

十字利夏地区

Description

一种CrosshairObject指定十字极兴趣区域(ROI)的位置。您可以自定义ROI的外观和交互式行为。

有关使用此ROI的更多信息,包括键盘快捷键,请参阅Tips

水平线和垂直线相交,形成十字线。

创建

有两种方法可以创造一个Crosshair目的。For more information, seeCreate ROI Shapes

  • 使用画crosshair功能。Use this function when you want to create the ROI and set the appearance in a single command. You can specify the position of the ROI interactively by drawing the ROI over an image using the mouse, or programmatically by using name-value arguments.

  • 使用images.roi.Crosshair这里描述的功能。在指定ROI的位置之前,请使用此函数在指定ROI的位置之前。创建对象后,您可以使用该对象以交互方式指定位置通过修改对象的属性来函数或以编程方式方式。

Description

例子

ROI.= images.roi.Crosshaircreates aCrosshair目的W.ith default properties.

ROI.= images.roi.crosshair(斧头的)在指定的轴中创建ROI斧头

ROI.= images.roi.crosshair(___名称,价值的)特性使用名称值参数的ROI。您可以指定多个名称值参数。将每个属性名称括在单引号中。

Example:images.roi.crosshair('颜色','y')产生一个黄色的彩色Crosshair目的。

输入参数

expand all

投资回报员的父母那specified as an一种Xes对象或A.UIAxes目的。有关在UIAXES中使用ROI的信息,包括重要限制,请参阅在使用App Designer创建的应用中使用ROIS

Properties

expand all

ROI颜色,指定为RGB三联,颜色名称或短颜色名称。

您可以使用RGB三重态指定任何颜色。RGB三联网是一个3元素的行向量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内[0,1]。

您可以按名称指定一些常见颜色作为字符串标量或字符向量。此表列出了命名的颜色选项和等效的RGB三元组。

颜色名称 Short Name RGB三重态 外貌
'红色的' 'r' [1 0 0]

一个矩形纯红色

'绿色' 'g' [0 1 0]

一种rectangle colored pure green

'blue' 'B' [0 0 1]

矩形彩色纯蓝色

'青色' 'C' [0 1 1]

矩形彩色纯青色

'magenta' 'm' [1 0 1]

一个矩形彩色纯洋红色

'yellow' '是' [1 1 0]

一种rectangle colored pure yellow

'黑色的' 'k' [0 0 0]

一种rectangle colored black

'白色的' 'W' [1 1 1]

矩形彩色白色

以下是MATLAB的默认颜色的RGB三元组®在许多类型的图中使用。

RGB三重态 外貌
[0 0.4470 0.7410]

一种rectangle colored medium blue

[0.8500 0.3250 0.0980]

一种rectangle colored reddish-orange

[0.9290 0.6940 0.1250]

矩形彩色黄色

[0.4940 0.1840 0.5560]

一种rectangle colored dark purple

[0.4660 0.6740 0.1880]

矩形彩色浅绿色

[0.3010 0.7450 0.9330]

一种rectangle colored light blue

[0.6350 0.0780 0.1840]

矩形彩色深红色

Example:'颜色','r'

Example:'颜色','绿色'

Example:'Color',[0 0.4470 0.7410]

右键单击ROI时显示的上下文菜单,指定为aContextMenu目的。You can create a custom context menu by using theuicontextmenu功能和then configuring context menu properties.

上下文菜单provides an option to delete the ROI, specified as真的要么错误的。当值是真的,您可以使用上下文菜单交互地删除ROI。当值是错误的那the context menu option to delete the ROI is disabled.

在这两种情况下,您可以通过使用删除上下文菜单之外的ROI删除功能。

您可以在其交互方式将ROI交互地放置的轴的区域,指定为此表中的值之一。

价值 Description
'汽车' The drawing area is the current axes limits (default).
'无限' 绘图区域没有边界,可以绘制或拖动ROI延伸以超出轴限制。
[x,y,w,h] The drawing area is restricted to a rectangular region beginning at (Xy),并延伸到宽度W.和身高H

ROI手柄的可见性孩子们父的属性,指定为此表中的值之一。

价值 Description
'在' 对象句柄始终可见(默认)。
'off' The object handle is hidden at all times.
'打回来' The object handle is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line.

ROI的交互性,指定为此表中的值之一。

价值 Description
'全部' ROI完全互动。
'没有' ROI不互动,无可见拖动点。

ROI标签那specified as a character vector or string scalar. By default, the ROI has no label ('')。

Transparency of the text background, specified as a number in the range [0, 1]. When set to1,文本背景完全不透明。设置到0.,文本背景是完全透明的。

标签文本颜色,指定为RGB三联网,颜色名称或短颜色名称。

您可以使用RGB三重态指定任何颜色。RGB三联网是一个3元素的行向量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内[0,1]。

您可以按名称指定一些常见颜色作为字符串标量或字符向量。此表列出了命名的颜色选项和等效的RGB三元组。

颜色名称 Short Name RGB三重态 外貌
'红色的' 'r' [1 0 0]

一个矩形纯红色

'绿色' 'g' [0 1 0]

一种rectangle colored pure green

'blue' 'B' [0 0 1]

矩形彩色纯蓝色

'青色' 'C' [0 1 1]

矩形彩色纯青色

'magenta' 'm' [1 0 1]

一个矩形彩色纯洋红色

'yellow' '是' [1 1 0]

一种rectangle colored pure yellow

'黑色的' 'k' [0 0 0]

一种rectangle colored black

'白色的' 'W' [1 1 1]

矩形彩色白色

以下是MATLAB在许多类型的图中使用的默认颜色的RGB三元组。

RGB三重态 外貌
[0 0.4470 0.7410]

一种rectangle colored medium blue

[0.8500 0.3250 0.0980]

一种rectangle colored reddish-orange

[0.9290 0.6940 0.1250]

矩形彩色黄色

[0.4940 0.1840 0.5560]

一种rectangle colored dark purple

[0.4660 0.6740 0.1880]

矩形彩色浅绿色

[0.3010 0.7450 0.9330]

一种rectangle colored light blue

[0.6350 0.0780 0.1840]

矩形彩色深红色

Example:'labeltextcolor','r'

Example:'labeltextcolor','绿色'

Example:'labeltextcolor',[0 0.4470 0.7410]

标签可见性那specified as one of these values.

价值 Description
'在' 标签is visible when the ROI is visible.
'hover' 只有在鼠标在ROI上悬停时,才能看到标签。
'off' 标签is not visible.

ROI边框的宽度,指定为点的正数。默认值是每个屏幕像素的点数的三倍,使得边框是三个像素宽。

ROI父母那specified as an一种Xes要么UIAxes目的。有关在UIAXES中使用ROI的信息,包括重要限制,请参阅在使用App Designer创建的应用中使用ROIS

ROI的位置,指定为表格的1×2数字矢量[x y]。The valuesXy指定X- 和y- 水平线在十字线ROI中穿过垂直线的位置的控制。当您绘制或移动ROI时,此值会自动更改。

选择ion state of the ROI, specified as the logical value真的要么错误的。您还可以以交互方式设置此属性。例如,单击ROI选择ROI并将此属性设置为真的。同样,按下Ctrl键和单击ROI取消选择ROI并将此属性的值设置为错误的

选择时,投资回报的颜色,指定为RGB三联网,颜色名称,短颜色名称或'没有'。If you specify'没有',那么值颜色为所有状态定义ROI的颜色,选择或不选择。

您可以使用RGB三重态指定任何颜色。RGB三联网是一个3元素的行向量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内[0,1]。

您可以按名称指定一些常见颜色作为字符串标量或字符向量。此表列出了命名的颜色选项和等效的RGB三元组。

颜色名称 Short Name RGB三重态 外貌
'红色的' 'r' [1 0 0]

一个矩形纯红色

'绿色' 'g' [0 1 0]

一种rectangle colored pure green

'blue' 'B' [0 0 1]

矩形彩色纯蓝色

'青色' 'C' [0 1 1]

矩形彩色纯青色

'magenta' 'm' [1 0 1]

一个矩形彩色纯洋红色

'yellow' '是' [1 1 0]

一种rectangle colored pure yellow

'黑色的' 'k' [0 0 0]

一种rectangle colored black

'白色的' 'W' [1 1 1]

矩形彩色白色

以下是MATLAB在许多类型的图中使用的默认颜色的RGB三元组。

RGB三重态 外貌
[0 0.4470 0.7410]

一种rectangle colored medium blue

[0.8500 0.3250 0.0980]

一种rectangle colored reddish-orange

[0.9290 0.6940 0.1250]

矩形彩色黄色

[0.4940 0.1840 0.5560]

一种rectangle colored dark purple

[0.4660 0.6740 0.1880]

矩形彩色浅绿色

[0.3010 0.7450 0.9330]

一种rectangle colored light blue

[0.6350 0.0780 0.1840]

矩形彩色深红色

Example:'selectscolor','r'

Example:'selectscolor','绿色'

Example:'SELISECTCOLOR',[0 0.4470 0.7410]

ROI条带的颜色,指定为RGB三联网,颜色名称,短颜色名称或'没有'。If you specify'没有',然后ROI边缘是指定的纯色颜色。否则,ROI的边缘是条纹的,颜色在指定的颜色之间交替颜色条纹镜头

您可以使用RGB三重态指定任何颜色。RGB三联网是一个3元素的行向量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内[0,1]。

您可以按名称指定一些常见颜色作为字符串标量或字符向量。此表列出了命名的颜色选项和等效的RGB三元组。

颜色名称 Short Name RGB三重态 外貌
'红色的' 'r' [1 0 0]

一个矩形纯红色

'绿色' 'g' [0 1 0]

一种rectangle colored pure green

'blue' 'B' [0 0 1]

矩形彩色纯蓝色

'青色' 'C' [0 1 1]

矩形彩色纯青色

'magenta' 'm' [1 0 1]

一个矩形彩色纯洋红色

'yellow' '是' [1 1 0]

一种rectangle colored pure yellow

'黑色的' 'k' [0 0 0]

一种rectangle colored black

'白色的' 'W' [1 1 1]

矩形彩色白色

以下是MATLAB在许多类型的图中使用的默认颜色的RGB三元组。

RGB三重态 外貌
[0 0.4470 0.7410]

一种rectangle colored medium blue

[0.8500 0.3250 0.0980]

一种rectangle colored reddish-orange

[0.9290 0.6940 0.1250]

矩形彩色黄色

[0.4940 0.1840 0.5560]

一种rectangle colored dark purple

[0.4660 0.6740 0.1880]

矩形彩色浅绿色

[0.3010 0.7450 0.9330]

一种rectangle colored light blue

[0.6350 0.0780 0.1840]

矩形彩色深红色

Example:'StripeColor','r'

Example:'ttimecolor','绿色'

Example:'riptecolor',[0 0.4470 0.7410]

标记与ROI关联,指定为字符向量或字符串标量。使用标记值使用标记值查找使用的对象层次结构中的ROI对象findobj.功能。

Data to associate with the ROI, specified as any MATLAB data. For example, you can specify a scalar, vector, matrix, cell array, string, character array, table, or structure. TheCrosshair目的does not use this data.

ROI可见性,指定为'在'要么'off',或作为数字或逻辑1(true) or0.(false). A value of'在'is equivalent to true, and'off'相当于假。该值存储为类型的开/关逻辑值OnOffSwitchState

价值 Description
'在' 显示ROI。
'off' Hide the ROI without deleting it. You still can access the properties of an invisible ROI.

对象功能

AddListener. 创建事件侦听器绑定到事件源
beginDrawingFromPoint Begin drawing ROI from specified point
takttofront. 将ROI带到轴上堆叠顺序的前面
以交互方式开始绘制ROI
等待 BlockMATLAB指令行直到ROI操作完成

Examples

全部收缩

将图像读入工作区并显示它。

I = imread('baby.jpg');数字;imshow(i)

以编程方式在图像上放置十字参考资料。指定ROI的位置时,必须指定轴。

h = images.roi.crosshair(gca,'Position'那[100,100]);

将图像读入工作区。

img = imread('coins.png');

在图中显示图像。

H一种X= gca; imObj = imshow(img,'父母'那H一种X);imObj.Parent.Visible ='在';

Create a crosshair ROI on the image.

h = images.roi.crosshair('父母',hax,'Position',[50 50],'LineWidth'那1那'Color''是');

Set up a listener to get notification when the ROI moves over the image. Because the code displays the value of the pixel under the crosshair, you must pass the image as an argument to the listener.

AddListener.(h,'搬家',@(src,data)displayinfo(src,data,hax,img));

定义displayInfo侦听器调用时的功能'搬家'event occurs.

功能displayinfo(〜,data,hax,img)pos = ceil(data.currentposition);标题(HAX,['像素值:',num2str(IMG(POS(2),POS(1))))])结尾

外貌of the image with title during interactive movement of the Crosshair ROI.

更多关于

expand all

Tips

  • 使用的交互式绘制投资回报率要么画crosshair功能那position the cursor over the image and click the mouse to draw the ROI.

  • The ROI supports the following interactivity, including keyboard shortcuts.

    任务 Description
    取消绘图操作。 退出。The function returns a valid ROI object with an empty位置财产。
    移动投资回报率。 位置the cursor over the center of the crosshair ROI (where the two lines cross) and click and drag the crosshair. Another way to move the crosshair ROI is to position the cursor anywhere on one of the two lines and click. The other line in the crosshair jumps to the new crosshair center position.
    Delete the ROI. 将光标定位在ROI上,右键单击,然后选择Delete Crosshair从上下文菜单中。您还可以通过使用的方式删除ROI删除功能。
  • 有关在使用App Designer创建的应用程序中使用ROI的信息,请参阅在使用App Designer创建的应用中使用ROIS

兼容性考虑因素

expand all

Not recommended starting in R2020a

介绍在R2019B.