Main Content

insertMarker

Insert markers in image or video

Description

example

RGB = insertMarker(I,position) returns a truecolor image with inserted plus (+) markers. The input image, I, can be either a truecolor or grayscale image. You draw the markers by overwriting pixel values. The input position can be either an M-by-2 matrix of M number of [x y] pairs or one of the Point Feature Types.

RGB = insertMarker(I,position,marker) returns a truecolor image with the marker type of markers inserted.

RGB = insertMarker(___,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, Color="red".

Examples

collapse all

Read the image.

I = imread('peppers.png');

Insert a plus (+) marker.

RGB = insertMarker(I,[147 279]);

Draw four x-marks.

pos   = [120 248;195 246;195 312;120 312];
color = {'red','white','green','magenta'};
RGB = insertMarker(RGB,pos,'x','color',color,'size',10);

Display the image.

imshow(RGB);

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

collapse all

Input image, specified in truecolor or 2-D grayscale.

Data Types: single | double | int16 | uint8 | uint16

Position of marker, specified as either an M-by-2 matrix of M number of [x y] pairs or one of the Point Feature Types. The center positions for the markers are defined by the [xy] pairs of the matrix or by the Location property of the point feature object.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Type of marker, specified as a character vector. The vector can be full text or the corresponding symbol.

Character VectorSymbol
"circle""o"
"x-mark""x"
"plus""+"
"star""*"
"square""s"

Data Types: char

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: Color="yellow" sets the marker color to yellow.

Size of marker in pixels, specified as a scalar value in the range [1, inf).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Marker color, specified as a character vector, cell array of character vectors, vector, or M-by-3 matrix. You can specify a different color for each marker or one color for all markers. Color values must be specified in the range [0,255]. Values that have a range of [0,1] must be scaled by a value of 255 before using it with this function. For example, [255 255 255].*colorvalue.

Supported colors are: "blue", "green", "red", "cyan", "magenta", "yellow","black", and "white".

ColorFormatExample
Specify one color for all markers

String or character color name

"r"

"red"

1-by-3 vector (RGB triplet)

[255 0 0]1-by-3 grid, with columns labeled r,g,b respectively.

Specify a color for each markerM-element vector

["red","yellow","blue"]

M-by-3 matrix, as a list of RGB values

255 0 0
255 0 0
0 255 255
M-by-3 grid, with columns labeled r,g,b respectively.

Data Types: cell | char | uint8 | uint16 | int16 | double | single

Output Arguments

collapse all

Output image, returned as a truecolor image.

Extended Capabilities

Version History

Introduced in R2013a