1

I have a binary image and I want to perform closing on that image with the line as structuring element. The openCv api has a function getStructuringElement that takes the following parameters

  • Shape
  • Size
  • Anchor Point

I can pass CV_SHAPE_CUSTOM in the first parameter to create a new shape but where do I pass the size and the values of my structuring element.

My line will be 10 pixels wide and 1 pixels in length basically {1,1,1,1,1,1,1,1,1,1}.

There is an old function createStructringElementEx but I don't want to use that as it involves a lot of conversion of datatype.

4

2 回答 2

0

Is this what you want?

Size = Size(10,1)

Anchor Point = Point(-1,-1)

于 2013-02-28T07:09:17.373 回答
0

Got it . Thanks to the comment from Niko.

Create a matrix as

Mat line = Mat::ones(1,10,CV_8UC1);
//now apply the morphology close operation
morphologyEx(img, img, MORPH_CLOSE, line,Point(-1,-1));

This solved my problem.

于 2013-02-28T07:27:10.690 回答