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) uses additional options specified by one or more Name,Value pair arguments.

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);

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 Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Color','yellow' specifies yellow for the marker color.

Size of marker in pixels, specified as the comma-separated pair consisting of 'Size' and a scalar value in the range [1, inf).

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

Marker color, specified as the comma-separated pair consisting of 'Color' and either a character vector, cell array of character vectors, vector, or matrix. You can specify a different color for each marker or one color for all markers.

To specify a color for each marker, set Color to a cell array of color character vectors or an M-by-3 matrix of M number of RGB (red, green, and blue) color values.

To specify one color for all markers, set Color to either a color character vector or an [R G B] vector. The [R G B] vector contains the red, green, and blue values.

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

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

Output Arguments

collapse all

Output image, returned as a truecolor image.

Extended Capabilities

Introduced in R2013a