From 33a8da663c8905073bd0cf8cd3f62ef79a6e18c5 Mon Sep 17 00:00:00 2001 From: syneffort Date: Sat, 11 Jun 2022 13:40:51 +0900 Subject: [PATCH] Morphology operation --- OpenCV/Form1.cs | 2 +- OpenCV/OpenCVClass.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OpenCV/Form1.cs b/OpenCV/Form1.cs index 74b1250..8de4261 100644 --- a/OpenCV/Form1.cs +++ b/OpenCV/Form1.cs @@ -41,7 +41,7 @@ namespace OpenCV pictureBoxIpl1.ImageIpl = src; Converter.ConvKernel = new IplConvKernel(3, 3, 1, 1, ElementShape.Rect); - pictureBoxIpl2.ImageIpl = Converter.EDImage(src, 50, 10); + pictureBoxIpl2.ImageIpl = Converter.MorphologyImage(src, MorphologyOperation.BlackHat, 10); } catch (Exception ex) { diff --git a/OpenCV/OpenCVClass.cs b/OpenCV/OpenCVClass.cs index 855a306..1298a7f 100644 --- a/OpenCV/OpenCVClass.cs +++ b/OpenCV/OpenCVClass.cs @@ -247,6 +247,18 @@ namespace OpenCV return morp; } + public IplImage MorphologyImage(IplImage src, MorphologyOperation option, int iteration) + { + if (convKernel == null) + return null; + + morp = new IplImage(src.Size, BitDepth.U8, 1); + bin = Binary(src, 50); + + Cv.MorphologyEx(bin, morp, bin, convKernel, option, iteration); + return morp; + } + public void Dispose() { Release(