Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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

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

Related Examples

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

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 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.

collapse all

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.

Introduced in R2013a

Was this topic helpful?