Executes morphological transformations such as dilation, erosion, opening, closing,
morphological gradient, top hat, black hat and hit ot miss on the given image,
handle.
Syntax
R = morphologyexcv(handle, operation, kernel...)
R = morphologyexcv(handle, operation, kernel, anchor, iterations, type, bordervalue)
Inputs
handle
Handle of an image.
Type: integer
operation
Type of morphological operation. Valid values are:
0
Erode
1
Dilate
2
Open
3
Close
4
Morphological gradient
5
Top hat
6
Black hat
7
Hit or miss
Type: integer
kernel
Structuring element used for dilation. This can be created using the command getstructuringelementcv.
An empty matrix, [] can also be used and a default structuring element will be used.
Type: integer | mat
anchor
Optional vector of 2 integers specifying the anchor position.
Default value is [-1 -1], indicating the anchor is at the center of the element.
Type: vector
iterations
Optional parameter specifying the number of times dilation or erosion is applied. Default value is 1.
Type: integer
type
Optional parameter specifying the pixel extrapolation method. Default value is 0.
Valid values are:
0
Type cv::BORDER_CONSTANT - default value
1
Type cv::BORDER_REPLICATE
2
Type cv::BORDER_REFLECT
4
Type cv::BORDER_REFLECT_101
16
Type cv::BORDER_ISOLATED
Type: integer
color
Optional 3-element vector of integers representing blue, green, red (BGR) colors, if type
is 0. Black will be the default color if nothing is specified with type.
Type: vector
Outputs
r
Handle of the resulting image.
Type: integer
Example
Dilates the given image:
handle = imreadcv('bird2.jpg');
R = morphologyexcv(handle, 1, eye(20));