-1

I am a beginner in OpenCv. I looked at opencv morphological dilation filter as maximum filter and how remove binary image noise in opencv? but I could not exactly understand how to use dilate function. I want to do some thing like this picture with the function:

http://up98.org/upload/server1/02/e/q42oinl73zpv7epkccrz.jpg

Would you please explain me step by step? Should I use this function?

void cvDilate(
     IplImage* src,
     IplImage* dst,
     IplConvKernel* B = NULL,
     int iterations = 1
)

If yes , what should i put instead of

IplImage* src
IplImage* dst
B
IplConvKernel* B = NUL
int iterations = 1

how is its Operation?

i mean that what should i do before i call the function?

what should i write in .h and .cpp

Thank you!!!

Community
  • 1
  • 1

1 Answers1

0

You are using the plain C OpenCV API. Nothing wrong, but I prefer the new C++ API

Regarding your question:

  • IplImage* src - is the source image, the one you already have and want it dilated;

  • IplImage* dst - is the destination image, that should only be declared prior to calling this funcion;

  • IplConvKernel* B - that's a bit harder to explain in short words, but thing of a tiny image, typically a 3x3 pixels, that will be use to get the features of your image "more fat" at each of the given number of iterations, check here. If you let it be a null pointer, the default value will be used, and it should suffice for most applications;

  • int iterations - the number of times that kernel will be used around the contour of the source image to turn its features more "fat" at each time;

As for your image, to achieve that result, you should first dilate for a certain number of iterations, then erode it back the same number of iterations.

Check this code here.

It uses the new C++ API, but you should not have problems into "translating" it back to the plain C API, as the structure of the functions are quite the same.

Hope it helps

ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53