Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use the function ‘cvCreateStructuringElementEx ()’?

Regards

I think in my previous post, “Create a structuring element of 3 * 3”, I do not clearly established what the problem was; maybe not well understood what I meant.

The problem is: how to use the function

cvCreateStructuringElementEx()

to create a structuring element of 3 * 3 with origin at the center (obviously a solid rectangular structuring element).

As I understand it, this is the structuring element that is created by default when none is given … Right?

So the question is: what parameters should I pass to the function?

I tested with the following:

(case 1) cvCreateStructuringElementEx (3, 3, 1, 1, CV_SHAPE_RECT);

and

(case 2) cvCreateStructuringElementEx (3, 3, -1, -1, CV_SHAPE_RECT);

In the first case I got an SE is not the one I’m waiting (I think), and that when used to dilate an image, as follows:

cvDilate (entrada_gris, dilatacion2, ee, iterations);

obtain a resulting image that is different from that obtained with:

cvDilate (entrada_gris, dilatacion1, NULL, iterations);

I think that the results should be the same (ie dilatacion1 = dilatacion2), but it is not.

In case 1, I conclude that one of the two structural elements (either ‘ee’ or the structuring element is created when passing NULL to function) is not a rectangular structuring element of 3 * 3 with origin at the center … Right?

In the second case an error is generated at runtime.

Thanks in advance to anyone who can provide some help regarding this issue.

By the way, I’m working with OpenCV 2.2.0 and 1.2.1 QtSDK under Windows 7 64-bit