I want to create a disk shaped structuring element on OpenCv. I need my SE to be similar with
sel = strel('disk',5);
I want to do this using
cvstructuringElementEx(cols,rows,anchor_x,anchor_y,shape,*values);
What do I need to do to achieve this and which values of anchor_x and anchor_y give the same center point of SE with MATLAB?
According to the docs, you could try:
cv::Mat sel = cv::getStructuringElement(MORPH_ELLIPSE, cv::Size(9,9));
This gave me the following structuring element:
0    0    0    0    1    0    0    0    0
0    1    1    1    1    1    1    1    0
0    1    1    1    1    1    1    1    0
1    1    1    1    1    1    1    1    1
1    1    1    1    1    1    1    1    1
1    1    1    1    1    1    1    1    1
0    1    1    1    1    1    1    1    0
0    1    1    1    1    1    1    1    0
0    0    0    0    1    0    0    0    0
While in MATLAB I got:
>> getnhood(strel('disk',5))
ans =
     0     0     1     1     1     1     1     0     0
     0     1     1     1     1     1     1     1     0
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     1     1     1     1     1     1     1     1     1
     0     1     1     1     1     1     1     1     0
     0     0     1     1     1     1     1     0     0
So not exactly the same but close enough :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With