getstructuringelementcv

Gets a structuring element that can be used for morphological commands on an image.

Syntax

R = getstructuringelementcv(shape, kernelsize)

R = getstructuringelementcv(shape, kernelsize, anchor)

Inputs

shape
Shape of R. Valid values are:
0
Rectangle.
1
Cross.
2
Ellipse.
Type: integer
kernelsize
Vector of two positive integers representing [width, height] of R.
Type: vector
anchor
Optional vector of 2 integers specifying anchor position of the element. Default value is [-1 -1], indicating the center of the kernel. Only option 2 of shape depends on anchor.
Type: vector

Outputs

R
Handle of the resulting structural element.
Type: integer

Example

Get the structuring element which can be used in dilation:

handle = imreadcv('image1.jpg');
kernel = getstructuringelementcv(1, [10 10]);
result = dilatecv(handle, kernel, [-1 -1], 1, 0, [255 0 0]);