Newer
Older
DeepTIAS / Main / ColorSubdivision / Form1.cs
@ke96 ke96 on 2 Nov 2020 1 KB Refactor
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;

namespace ColorSubdivision
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            var path = @"D:\kei2\Solutions\DeepTongue\LocalRepository\Tongue extraction_cropresizemethod\Tongue extraction\bin\x64\Debug\mask_final\20180315093610.jpg";
            using (Mat mat_input = Cv2.ImRead(path, ImreadModes.Grayscale))
            {
                var mat_dst = new Mat(mat_input.Size(), mat_input.Type());
                bool isEdge = false;
                for (int i = 0; i < mat_input.Height; i++)
                {
                    if(!isEdge)
                    {
                        for (int j = 0; j < mat_input.Width; j++)
                        {
                            if (mat_input.At<int>(i, j) > 200)
                            {
                                mat_dst.Set<int>(i, j, 100);
                                isEdge = true;
                            }
                        }
                    }
                }
                Cv2.ImShow("input", mat_input);
                Cv2.ImShow("dst", mat_dst);
                mat_dst.Dispose();
            }
            GC.Collect();
           
        }

        private void Button2_Click(object sender, EventArgs e)
        {

        }
    }
}