Unlike the python bindings for the OpenCv Dilate function, the C# version has more arguments that are all mandatory, and I'm not sure what to use for the elements for the element argument. I tried the following, and the output looks identical to the inpur:
public static void Dilate(
IInputArray src,
IOutputArray dst,
IInputArray element,
Point anchor,
int iterations,
BorderType borderType,
MCvScalar borderValue
)
In Python I would do something like:
kernel = np.ones((5,5),np.uint8)
dilation = cv2.dilate(src, kernel,iterations=3)
In C#, I tried using the Default values. but the output does not look any different than the input.
ScalarArray elem = new ScalarArray(0);
CvInvoke.Dilate(_cannyFrame
, _dilatedCanny
, elem
, new Point(-1,- 1)
, 6
, BorderType.Constant
, new MCvScalar(255, 255, 255) );
The error seems to be in the structuring element. You are using an elem
equal to zero and this has no effect on destination image _dilatedCanny
. In python you are using a kernel with ones element...
Try this
Mat element = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Rectangle, new Size(3, 3), new Point(-1, -1));
CvInvoke.Dilate(_cannyFrame
, _dilatedCanny
, element
, new Point(-1,- 1)
, 6
, BorderType.Constant
, new MCvScalar(255, 255, 255) );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.