Documentation Center

  • Trial Software
  • Product Updates

insertMarker

Insert markers in image or video

Syntax

  • RGB = insertMarker(I,position) example
  • RGB = insertMarker(I,position,marker) example
  • RGB = insertMarker(___,Name,Value)

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 a cornerPoints object.

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.

Code Generation Support:
Compile-time constant input: marker
Supports MATLAB® Function block: Yes
Code Generation Support, Usage Notes, and Limitations

Examples

expand all

Draw Markers on an Image

Read the image.

I = imread('peppers.png');

Draw a plus (+).

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

expand all

I — Input imageM-by-N-by-3 truecolor | M-by-N 2-D grayscale image

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

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

position — Position of markerM-by-2 matrix | vector

Position of marker, specified as either an M-by-2 matrix of M number of [x y] pairs or a cornerPoints object. The center positions for the markers are defined by either the [xy] pairs of the matrix or by the position.Location property of the cornerPoints object.

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

marker — Type of marker'plus' (default) | character string

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

StringSymbol String
'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 single 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' — Size of marker3 (default) | scalar value

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

'Color' — Marker color'green' (default) | character string | cell array of character strings | vector | matrix

Marker color, specified as the comma-separated pair consisting of 'Color' and either a string, cell array of strings, 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 strings 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 string or an [R G B] vector. The [R G B] vector contains the red, green, and blue values.

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

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

Output Arguments

expand all

RGB — Output imageM-by-N-by-3 truecolor

Output image, returned as a truecolor image.

See Also

| | |

Was this topic helpful?