OpenCV腐蚀图像和图像模糊
找了些c++的OpenCV资料,照着抄打成c#试试,灰度转换老是报错,不知道是不是我下载的库不对。
//腐蚀图像
//Mat srcImg = new Mat(@"D:\a.png", ImreadModes.Color);
//Cv2.ImShow("src", srcImg);
//Mat element = Cv2.GetStructuringElement(MorphShapes.Rect, new OpenCvSharp.Size(15, 15));
//Mat desImg = new Mat();
//Cv2.Erode(srcImg, desImg, element);
//Cv2.ImShow("desct", desImg);
//Cv2.WaitKey(0);
//图像模糊
//Mat srcImg = new Mat(@"D:\a.png", ImreadModes.Color);
//Cv2.ImShow("src", srcImg);
//Mat destImg = new Mat();
//Cv2.Blur(srcImg, destImg, new OpenCvSharp.Size(7, 7));
//Cv2.ImShow("desct", destImg);
//Cv2.WaitKey(0);
//边缘检测
Mat srcImg = new Mat(@"D:\a.png", ImreadModes.Color);
Cv2.ImShow("src", srcImg);
Mat destImg = new Mat();
//destImg.Create(srcImg.Size(), srcImg.Type());
//图像转换为灰度图像
Cv2.CvtColor(srcImg, destImg,ColorConversionCodes.BayerRG2RGB_VNG);
Cv2.ImShow("desct", destImg);
Cv2.WaitKey(0);