Ejemplo n.º 1
0
        private static void SobelFilter(FileInfo file, string outputFileName)
        {
            Console.WriteLine("***SOBEL FILTER***");

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            using (var imageLoader = new ImageLoader())
            {
                imageLoader.Load(file.FullName);
                imageLoader.AddNoise(new GaussNoise(new Normal(0.0001, 0.0001)));
                Image I = imageLoader.Image;

                //Image Gh = imageLoader.AddSobelFilter("H").Image;
                //imageLoader.Save($"{outputFileName}_GH_sobel{file.Extension}");
                //imageLoader.Image = I;
                //Image Gv = imageLoader.AddSobelFilter("V").Image;
                //imageLoader.Save($"{outputFileName}_GV_sobel{file.Extension}");

                double[,] Gv = imageLoader.GetSobelFilterDouble("V");
                double[,] Gh = imageLoader.GetSobelFilterDouble("H");

                Image ColorMap = Filters.SobelFilter.GetColorMap(Gv, Gh);

                imageLoader.Image = ColorMap;
                imageLoader.Save($"{outputFileName}_sobel_ColorMap_{file.Extension}");

                for (int thr = 15; thr < 200; thr += 10)
                {
                    Image BinaryCard = Filters.SobelFilter.GetBinaryCard(thr, Gv, Gh);
                    imageLoader.Image = BinaryCard;
                    imageLoader.Save($"{outputFileName}_sobel_BinaryCard_(thr={thr}){file.Extension}");
                }
            }
        }