| Video and Image Processing Blockset™ | ![]() |
Draw markers by embedding predefined shapes on output image
Text & Graphics

The Draw Markers block can draw multiple circles, x-marks, plus signs, stars, or squares on images by overwriting pixel values. As a result, the shapes are embedded on the output image.
This block uses Bresenham's circle drawing algorithm to draw circles and Bresenham's line drawing algorithm to draw all other markers.
| Port | Input/Output | Supported Data Types | Complex Values Supported |
|---|---|---|---|
Image | M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes |
| No |
R, G, B | Scalar, vector, or matrix that represents one plane of the input RGB video stream. Inputs to the R, G, and B ports must have the same dimensions and data type. | Same as I port | No |
Pts | 2-by-N matrix of row and column pairs,
where N is the total number of markers and each row and column pair defines the center of a marker. |
If the input to the Image port is an integer data type, the input to the Pts port must also be an integer data type. | No |
ROI | Four-element vector of integers that define a rectangular area in which to draw the shapes. The first two elements represent the zero-based row and column coordinates of the upper-left corner of the area. The second two elements represent the height and width of the area. |
| No |
Output | Scalar, vector, or matrix of pixel values that contain the shape(s) | Same as I port | No |
The output signal is the same size and data type as the inputs to the Image, R, G, and B ports.
Use the Marker shape parameter to specify the shape of the markers. Your choices are Circle, X-mark, Plus, Star, or Square.
Use the Marker size parameter to define the size of the marker, in pixels. Enter a scalar value, M, that defines a 2M-by-2M pixel square into which the marker fits. M must be greater than or equal to 1.
If you clear the Filled check box, the Border value parameter appears in the dialog box. Use this parameter to determine the appearance of any markers. If you select Black, the border is black. If you select White, the border is white. If you select User-specified value, the Value(s) parameter appears in the dialog box. The following table describes the what to enter for the Value(s) parameter based on the block input and the number of markers you are drawing:
| Block Input | Drawing One Shape | Drawing Multiple Shapes |
|---|---|---|
| Intensity image | Value(s) = Scalar intensity value | Value(s) = R-element vector where R is the number of shapes |
| Color image | Value(s) = P-element vector where P is the number of color planes | Value(s) = P-by-R matrix where P is the number of color planes and R is the number of shapes |
For each value in the Value(s) parameter, enter a number between the minimum and maximum values that can be represented by the data type of the input image. If you enter a value outside this range, the block produces an error message.
If you select the Filled check box, the Fill value and Opacity factor (between 0 and 1) parameters appear in the dialog box. Use the Fill value parameter to specify the shading inside the shape. If you select Black, the shape is black. If you select White, the shape is white. If you select User-specified value, the Value(s) parameter appears in the dialog box. For a description of this parameter, see the preceding table. Use the Opacity factor (between 0 and 1) parameter to specify the opacity of the shading inside the shape, where 0 is transparent and 1 is opaque.
Note If you are generating code and you select the Filled check box, the word length of the block input(s) cannot exceed 16 bits. |
Use the Draw markers in parameter to define the area in which to draw the markers. If you select Entire image, you can draw markers in the entire image. If you select Specify region of interest via port, the ROI port appears on the block. Enter a four-element vector of integer values, [r c height width], where r and c are the row and column coordinates of the upper-left corner of the area, and height and width represent the height (in rows) and width (in columns) of the area. If you specify values that are outside the image, the block clips the values to the image boundaries.
If, for the Marker shape parameter, you select X-mark, Plus, or Star, and you select the Use antialiasing check box, the block performs the smoothing algorithm described in [1].
If, for the Marker shape parameter, you select Circle, and you select the Use antialiasing check box, the block performs a smoothing algorithm that is described next. First, the block calculates the distance from a point on the circle to the nearest pixel.

Then, it uses the following equations to calculate the intensity at pixels i and j:
![]()
In the previous equations, factor is the value you entered for the Opacity factor (between 0 and 1) parameter. If you did not enter an opacity factor, the block sets it to 1. I is the value you entered for the Border value or Fill value parameter.
Use the Image signal parameter to specify how to input and output a color video signal. If you select One multidimensional signal, the block accepts an M-by-N-by-P color video signal, where P is the number of color planes, at one port. If you select Separate color signals, additional ports appear on the block. Each port accepts one M-by-N plane of an RGB video stream.
The Draw Markers dialog box appears as shown in the following figure.

Specify the type of marker(s) to draw. Your choices are Circle, X-mark, Plus, Star, or Square.
Enter a scalar value that represents the size of the marker, in pixels.
Select this check box to fill the marker with an intensity value or a color. This parameter is visible if, for the Marker shape parameter, you choose Circle or Square.
Specify the appearance of the marker. If you select Black, the marker is black. If you select White, the marker border is white. If you select User-specified value, the Value(s) parameter appears in the dialog box.
Specify how to fill the marker. If you select Black, the block fills the marker with black. If you select White, the block fills the marker with white. If you select User-specified value, the Value(s) parameter appears in the dialog box. This parameter is visible if you select the Filled check box.
Specify an intensity or color value for the marker's border. This parameter is visible if, for the Border value or Fill value parameter, you select User-specified value. This parameter is tunable.
Specify the opacity of the shading inside the marker, where 0 is transparent and 1 is opaque. This parameter is visible if you select the Filled check box. This parameter is tunable when Use antialiasing is not selected.
Define the area in which to draw the markers. If you select Entire image, you can draw markers in the entire image. If you select Specify region of interest via port, the ROI port appears on the block. Enter a four-element vector, [r c height width], where r and c are the row and column coordinates of the upper-left corner of the area, and height and width represent the height (in rows) and width (in columns) of the area.
Select this check box to perform a smoothing algorithm on the marker. This parameter is visible if, for the Marker shape parameter, you select Circle, X-mark, Plus, or Star.
Specify how to input and output a color video signal. If you select One multidimensional signal, the block accepts an M-by-N-by-P color video signal, where P is the number of color planes, at one port. If you select Separate color signals, additional ports appear on the block. Each port accepts one M-by-N plane of an RGB video stream.
[1] Gupta, S. and R.F. Sproull, "Filtering Edges for Gray-Scale Displays", Computer Graphics, Vol. 15, No. 3, August 1981.
Video and Image Processing Blockset | |
Video and Image Processing Blockset |
![]() | Dilation | Draw Shape (Obsolete) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |