static void Main(String[] args) { Mat img = CvInvoke.Imread(@"C:UsersdellPicturesfaces.png",0); Mat d = new Mat(); Mat e = new Mat(); Mat element = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(5, 5),new Point(-1,-1)); CvInvoke.Dilate(img, d, element, new Point(-1, -1),1,BorderType.Default,new MCvScalar(128,128,128)); CvInvoke.Erode(img, e, element, new Point(-1, -1), 1, BorderType.Default, new MCvScalar(128, 128, 128)); CvInvoke.Imshow("img", img); CvInvoke.Imshow("Dilate", d); CvInvoke.Imshow("Erode", e); CvInvoke.WaitKey(0); }