From 0b574b73425dc009c18d6d2b6197870b8416d9fa Mon Sep 17 00:00:00 2001 From: syneffort Date: Sat, 11 Jun 2022 08:51:46 +0900 Subject: [PATCH] inversion, binary --- OpenCV/Form1.cs | 3 ++- OpenCV/OpenCVClass.cs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/OpenCV/Form1.cs b/OpenCV/Form1.cs index 4930c31..b46e37a 100644 --- a/OpenCV/Form1.cs +++ b/OpenCV/Form1.cs @@ -39,7 +39,8 @@ namespace OpenCV OpenCVClass Converter = new OpenCVClass(); pictureBoxIpl1.ImageIpl = src; - pictureBoxIpl2.ImageIpl = Converter.GrayScale(src); + //pictureBoxIpl2.ImageIpl = Converter.InversionImage(src); + pictureBoxIpl2.ImageIpl = Converter.Binary(src); } catch (Exception ex) { diff --git a/OpenCV/OpenCVClass.cs b/OpenCV/OpenCVClass.cs index 631d08b..c9ef521 100644 --- a/OpenCV/OpenCVClass.cs +++ b/OpenCV/OpenCVClass.cs @@ -6,6 +6,8 @@ namespace OpenCV class OpenCVClass : IDisposable { IplImage gray; + IplImage inversion; + IplImage bin; public IplImage GrayScale(IplImage src) { @@ -14,10 +16,28 @@ namespace OpenCV return gray; } + public IplImage InversionImage(IplImage src) + { + inversion = new IplImage(src.Size, BitDepth.U8, 3); + Cv.Not(src, inversion); + return inversion; + } + + public IplImage Binary(IplImage src) + { + bin = GrayScale(src); + Cv.Threshold(bin, bin, 150, 255, ThresholdType.Binary); + return bin; + } + public void Dispose() { if (gray != null) Cv.ReleaseImage(gray); + if (inversion != null) + Cv.ReleaseImage(inversion); + if (bin != null) + Cv.ReleaseImage(bin); } } }