public void TestMethod6()
        {
            double[,] img = ImageHelper.LoadImage(TestResource._81_7);
            double sigma = 1.4d;

            double[,] smoothing = LocalBinarizationCanny.Smoothing(img, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            int sizeWin = 16;

            double[,] resImg = LocalBinarizationCanny.LocalBinarization(img, nonMax, sizeWin, 1.3d);
            PoreFilter.DeletePores(resImg);
            var path = Path.GetTempPath() + "BinarizatedPoreFiltred81_7.png";

            ImageHelper.SaveArray(resImg, path);
            Process.Start(path);
            var path2   = Path.GetTempPath() + "Thinned81_7.png";
            var resImg2 = Thining.ThinPicture(resImg);

            ImageHelper.SaveArray(resImg2, path2);
            Process.Start(path2);
            var list  = MinutiaeDetection.FindMinutiae(resImg2);
            var list2 = MinutiaeDetection.FindBigMinutiae(list);
            var path3 = Path.GetTempPath() + "MinutiaeMatchedTest81_7.png";

            ImageHelper.MarkMinutiae(path2, list2, path3);
            Process.Start(path3);
        }
        public void TestMethod11()
        {
            double[,] img = ImageHelper.LoadImage(TestResource._81_81);
            double sigma = 1.4d;

            double[,] smoothing = LocalBinarizationCanny.Smoothing(img, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            int sizeWin = 16;

            double[,] resImg = LocalBinarizationCanny.LocalBinarization(img, nonMax, sizeWin, 1.3d);
            PoreFilter.DeletePores(resImg);
            PoreFilter.DeletePores(resImg);
            var path = "C:\\temp\\BinarizatedPoreFiltred81_81.png";

            ImageHelper.SaveArray(resImg, path);
            ImageHelper.SaveImageAsBinary(path, "C:\\temp\\BinarizatedPoreFiltred81_81.bin");
            ImageHelper.SaveBinaryAsImage("C:\\temp\\Thinned81_81.bin", "C:\\temp\\Thinned81_81.png", true);
            ImageHelper.SaveBinaryAsImage("C:\\temp\\MinutiaeMatched81_81.bin", "C:\\temp\\MinutiaeMatched81_81.png", true);
            Process.Start("C:\\temp\\MinutiaeMatched81_81.png");
            Process.Start("C:\\temp\\Thinned81_81.png");
            //System.Console.WriteLine(path);
        }
Пример #3
0
        public void TestWithAdequateMinutiaeSet()
        {
            int[,] mask           = Segmentator.Segmetator(img, windowSize, weight, threshold);
            double[,] binaryImage = img; //
            //---------------------------------------
            double sigma = 1.4d;

            double[,] smoothing = LocalBinarizationCanny.Smoothing(binaryImage, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            int sizeWin = 16;

            binaryImage = LocalBinarizationCanny.LocalBinarization(binaryImage, nonMax, sizeWin, 1.3d);
            //---------------------------------------
            binaryImage = Thining.ThinPicture(binaryImage);
            //---------------------------------------
            List <Minutia> minutiae = MinutiaeDetection.FindMinutiae(binaryImage);

            for (int i = 0; i < minutiae.Count; i++)
            {
                if (mask[minutiae[i].Y, minutiae[i].X] == 0)
                {
                    minutiae.Remove(minutiae[i]);
                    i--;
                }
            }

            minutiae = MinutiaeDetection.FindBigMinutiae(minutiae);

            var response = MCC.MCCMethod(minutiae, img.GetLength(0), img.GetLength(1));

            SaveResponse(response, minutiae);
        }
Пример #4
0
        private static void TestCUDAThining()
        {
            var img = ImageHelper.LoadImage(Resources._104_6);

            GlobalBinarization.Binarization(img, 150);
            int[] startImg = new int[img.GetLength(0) * img.GetLength(1)];
            int[] result   = new int[img.GetLength(0) * img.GetLength(1)];
            double[,] thining = new double[img.GetLength(0), img.GetLength(1)];
            for (int i = 0; i < img.GetLength(0); i++)
            {
                for (int j = 0; j < img.GetLength(1); j++)
                {
                    startImg[i * img.GetLength(1) + j] = (int)img[i, j];
                }
            }
            CUDAThining(startImg, img.GetLength(1), img.GetLength(0), result);
            for (int i = 0; i < img.GetLength(0); i++)
            {
                for (int j = 0; j < img.GetLength(1); j++)
                {
                    thining[i, j] = (double)result[i * img.GetLength(1) + j];
                }
            }

            var path = Path.GetTempPath() + "thininig.png";

            ImageHelper.SaveArray(thining, path);
            Process.Start(path);
        }
        public void TestMethod4()
        {
            double board = 153d;
            var    img   = ImageHelper.LoadImage(TestResource._110_6);

            double[,] binarization = GlobalBinarization.Binarization(img, board);
            var path = Path.GetTempPath() + "globalBinarization" + board + ".png";

            ImageHelper.SaveArray(binarization, path);
            Process.Start(path);
        }
        public void TestMethodSobel()
        {
            var img = ImageHelper.LoadImage(TestResource._104_6_ench);

            double[,] sobel  = LocalBinarizationCanny.Sobel(img);
            double[,] nonMax = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            double[,] gl     = GlobalBinarization.Binarization(nonMax, 60);
            gl = LocalBinarizationCanny.Inv(gl);
            var path = Path.GetTempPath() + "localBinSobel11.png";

            ImageHelper.SaveArray(gl, path);
            Process.Start(path);
        }
        public void TestMethod5()
        {
            double sigma = 1.4d;
            var    img   = ImageHelper.LoadImage(TestResource._104_6);

            double[,] smoothing = LocalBinarizationCanny.Smoothing(img, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 50);
            var path = Path.GetTempPath() + "localSol" + sigma + ".png";

            ImageHelper.SaveArray(nonMax, path);
            Process.Start(path);
        }
        public void TestMethod2()
        {
            //var img = ImageHelper.LoadImage(TestResource._104_6);
            var    img     = ImageHelper.LoadImage(TestResource._104_6);
            double board   = 5;
            var    thining = Thining.ThinPicture(GlobalBinarization.Binarization(img, board));
            var    path    = Path.GetTempPath() + "MinutiaeMarkedThinnedBinarizated" + board + ".png";

            ImageHelper.MarkMinutiae(ImageHelper.SaveArrayToBitmap(thining), MinutiaeDetection.FindMinutiae(thining), path);
            //Trace.WriteLine(MinutiaeDetection.FindMinutiae(img));
            //ImageHelper.SaveArray(Detection, path);
            //ImageHelper.SaveArray(thining, path);
            Process.Start(path);
        }
Пример #9
0
        public float[] BinarizeImage(float[] image, int rows, int columns, bool useCuda = false)
        {
            if (useCuda)
            {
                var result = new float[rows * columns];
                CudaGlobalBinarization((float)Constants.BinarizationThreshold, result, image, columns, rows);
                return(result);
            }
            var newImage = ImageEnhancementHelper.EnhanceImage(image.Make2D(rows, columns).Select2D(x => (double)x));

            return
                (GlobalBinarization.Binarization(newImage, Constants.BinarizationThreshold)
                 .Make1D()
                 .Select(x => (float)x)
                 .ToArray());
        }
Пример #10
0
        public void TestMcc()
        {
            int[,] maskOfSegmentation2D = Segmentator.Segmetator(img, windowSize, weight, threshold);
            var            thining       = Thining.ThinPicture(GlobalBinarization.Binarization(img, board));
            List <Minutia> minutiaList   = MinutiaeDetection.FindMinutiae(thining);
            List <Minutia> validMinutiae = new List <Minutia>();

            foreach (Minutia minutia in minutiaList)
            {
                if (maskOfSegmentation2D[minutia.Y, minutia.X] == 1) // coordinates swap - ok
                {
                    validMinutiae.Add(minutia);
                }
            }

            var response = MCC.MCCMethod(validMinutiae, thining.GetLength(0), thining.GetLength(1));

            SaveResponse(response, validMinutiae);
        }
        public void TestMethod1()
        {
            //var img = ImageHelper.LoadImage(TestResource._104_6);
            double sigma = 1.4d;
            var    img   = ImageHelper.LoadImage(TestResource._90_3);

            double[,] smoothing = LocalBinarizationCanny.Smoothing(img, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            int sizeWin = 16;

            double[,] resImg = LocalBinarizationCanny.LocalBinarization(img, nonMax, sizeWin, 1.3d);
            var path    = Path.GetTempPath() + "thininig.png";
            var thining = Thining.ThinPicture(img);

            ImageHelper.SaveArray(thining, path);
            Process.Start(path);
        }
        public void TestLocalBinarization()
        {
            double sigma = 1.4d;
            var    img   = ImageHelper.LoadImage(TestResource._90_3);

            double[,] smoothing = LocalBinarizationCanny.Smoothing(img, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            var path = Path.GetTempPath() + "nonMax" + ".png";

            ImageHelper.SaveArray(nonMax, path);
            Process.Start(path);
            int sizeWin = 16;

            double[,] resImg = LocalBinarizationCanny.LocalBinarization(img, nonMax, sizeWin, 1.3d);
            path             = Path.GetTempPath() + "localSol" + sizeWin + ".png";
            ImageHelper.SaveArray(resImg, path);
            Process.Start(path);
        }
        public void FindDirectionTest()
        {
            for (int cur = 1; cur <= 10; cur++)
            {
                double[,] startImg = ImageHelper.LoadImage(TestResource.SampleFinger2);
                int imgHeight = startImg.GetLength(0);
                int imgWidth  = startImg.GetLength(1);
                //-------------------------------
                int[]   mask             = new int[imgHeight * imgWidth];
                int     windowSize       = 12;
                float   WeightConstant   = 0.3F;
                int     maskHeight       = imgHeight / windowSize;
                int     maskWidth        = imgWidth / windowSize;
                float[] imgToSegmentator = new float[imgHeight * imgWidth];
                for (int i = 0; i < imgHeight; i++)
                {
                    for (int j = 0; j < imgWidth; j++)
                    {
                        imgToSegmentator[i * imgWidth + j] = (float)startImg[i, j];
                    }
                }

                CUDASegmentator(imgToSegmentator, imgWidth, imgHeight, WeightConstant, windowSize, mask, maskWidth,
                                maskHeight);

                //----------------------------------

                double sigma = 1.4d;
                double[,] smoothing = LocalBinarizationCanny.Smoothing(startImg, sigma);
                double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
                double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
                nonMax = GlobalBinarization.Binarization(nonMax, 60);
                nonMax = LocalBinarizationCanny.Inv(nonMax);
                int sizeWin = 16;
                startImg = LocalBinarizationCanny.LocalBinarization(startImg, nonMax, sizeWin, 1.3d);
                startImg = GlobalBinarization.Binarization(startImg, 140);
                //-------------------------------

                startImg = Thining.ThinPicture(startImg);

                //-------------------------------
                for (int i = 0; i < imgHeight; i++)
                {
                    for (int j = 0; j < imgWidth; j++)
                    {
                        if (mask[i / windowSize * maskWidth + j / windowSize] == 0)
                        {
                            startImg[i, j] = 255;
                        }
                    }
                }
                //var path1 = System.IO.Path.GetTempPath() + "lol.png";
                //ImageHelper.SaveArray(startImg, path1);
                //-------------------------------

                int[,] BinaryImage         = ImageHelper.ConvertDoubleToInt(startImg);
                double[,] OrientationField =
                    Common.OrientationField.OrientationFieldGenerator.GenerateOrientationField(
                        BinaryImage);

                //-------------------------------
                Stopwatch sw = new Stopwatch();

                List <Minutia> Minutiae = MinutiaeDetection.FindMinutiae(startImg);
                //--------------------------------
                List <Minutia> TrueMinutiae = new List <Minutia>();
                for (int i = 0; i < Minutiae.Count; i++)
                {
                    if (mask[Minutiae[i].Y / windowSize * maskWidth + Minutiae[i].X / windowSize] != 0)
                    {
                        TrueMinutiae.Add(Minutiae[i]);
                    }
                }
                Minutiae = TrueMinutiae;

                //--------------------------------
                sw.Start();
                Minutiae = MinutiaeDetection.FindBigMinutiae(Minutiae);
                sw.Stop();
                //-------------------------------

                /*MinutiaeDirection.FindDirection(OrientationField, 16, Minutiae, BinaryImage, 1);
                 *
                 * //-------------------------------
                 *
                 * var path = "D:\\MyData\\Documents\\Results\\1\\" + cur + ".png";
                 * ImageHelper.MarkMinutiaeWithDirections(path1, Minutiae, path);
                 *
                 * //-------------------------------
                 *
                 * MinutiaeDirection.FindDirection(OrientationField, 16, Minutiae, BinaryImage, 4);
                 *
                 * //-------------------------------
                 *
                 * path = "D:\\MyData\\Documents\\Results\\2\\" + cur + ".png";
                 * ImageHelper.MarkMinutiaeWithDirections(path1, Minutiae, path);
                 *
                 * //-------------------------------
                 *
                 * MinutiaeDirection.FindDirection(OrientationField, 16, Minutiae, BinaryImage, 2);
                 *
                 * //-------------------------------
                 *
                 * path = "D:\\MyData\\Documents\\Results\\3\\" + cur + ".png";
                 * ImageHelper.MarkMinutiaeWithDirections(path1, Minutiae, path);*/

                //-------------------------------

                MinutiaeDirection.FindDirection(OrientationField, 16, Minutiae, BinaryImage, 4);

                Trace.WriteLine(string.Format("Minutiae detection and direction took {0} ms", sw.ElapsedMilliseconds));
                //-------------------------------

                var path = Path + Guid.NewGuid() + ".png";
                ImageHelper.MarkMinutiaeWithDirections(TestResource.SampleFinger2, Minutiae, path);
                Process.Start(path);
            }
        }
Пример #14
0
        private static void TestCUDADirections()
        {
            double[,] startImg = ImageHelper.LoadImage(Resources._7_6start);
            int imgHeight = startImg.GetLength(0);
            int imgWidth  = startImg.GetLength(1);

            int[] mask           = new int[imgHeight * imgWidth];
            int   windowSize     = 12;
            float WeightConstant = 0.3F;
            int   maskHeight     = imgHeight / windowSize;
            int   maskWidth      = imgWidth / windowSize;

            float[] imgToSegmentator = new float[imgHeight * imgWidth];
            for (int i = 0; i < imgHeight; i++)
            {
                for (int j = 0; j < imgWidth; j++)
                {
                    imgToSegmentator[i * imgWidth + j] = (float)startImg[i, j];
                }
            }

            CUDASegmentator(imgToSegmentator, imgWidth, imgHeight, WeightConstant, windowSize, mask, maskWidth, maskHeight);


            double[,] binaryImage = ImageHelper.LoadImage(Resources._7_6);
            //---------------------------------------
            double sigma = 1.4d;

            double[,] smoothing = LocalBinarizationCanny.Smoothing(binaryImage, sigma);
            double[,] sobel     = LocalBinarizationCanny.Sobel(smoothing);
            double[,] nonMax    = LocalBinarizationCanny.NonMaximumSupperession(sobel);
            nonMax = GlobalBinarization.Binarization(nonMax, 60);
            nonMax = LocalBinarizationCanny.Inv(nonMax);
            int sizeWin = 16;

            binaryImage = LocalBinarizationCanny.LocalBinarization(binaryImage, nonMax, sizeWin, 1.3d);
            //---------------------------------------
            binaryImage = Thining.ThinPicture(binaryImage);
            //---------------------------------------
            List <Minutia> Minutiae = MinutiaeDetection.FindMinutiae(binaryImage);

            for (int i = 0; i < Minutiae.Count; i++)
            {
                if (mask[Minutiae[i].Y / windowSize * maskWidth + Minutiae[i].X / windowSize] == 0)
                {
                    Minutiae.Remove(Minutiae[i]);
                    i--;
                }
            }
            Minutiae = MinutiaeDetection.FindBigMinutiae(Minutiae);
            //--------------------------------------
            int[,] intImage            = ImageHelper.ConvertDoubleToInt(binaryImage);
            double[,] OrientationField = OrientationFieldGenerator.GenerateOrientationField(intImage);
            for (int i = 0; i < OrientationField.GetLength(0); i++)
            {
                for (int j = 0; j < OrientationField.GetLength(1); j++)
                {
                    if (OrientationField[i, j] < 0)
                    {
                        OrientationField[i, j] += Math.PI;
                    }
                }
            }
            //--------------------------------------
            int orHeight = OrientationField.GetLength(0);
            int orWidth  = OrientationField.GetLength(1);

            double[] myOrientationField = new double[orHeight * orWidth];
            for (int i = 0; i < orHeight; i++)
            {
                for (int j = 0; j < orWidth; j++)
                {
                    myOrientationField[i * orWidth + j] = OrientationField[i, j];
                }
            }
            //---------------------------------------
            int NoM = Minutiae.Count;

            int[] myMinutiae = new int[2 * NoM];
            for (int i = 0; i < NoM; i++)
            {
                myMinutiae[2 * i]     = Minutiae[i].X;
                myMinutiae[2 * i + 1] = Minutiae[i].Y;
            }
            //-----------------------------------------------
            double[] Directions = new double[NoM];
            //------------------------------------------
            int[] BinaryImage = new int[imgWidth * imgHeight];
            for (int i = 0; i < imgHeight; i++)
            {
                for (int j = 0; j < imgWidth; j++)
                {
                    BinaryImage[i * imgWidth + j] = intImage[i, j];
                }
            }
            //----------------------------------------
            FindDirection(myOrientationField, orHeight, orWidth, 16, myMinutiae, NoM, BinaryImage, imgHeight, imgWidth, Directions);
            for (int i = 0; i < NoM; i++)
            {
                var temp = Minutiae[i];
                temp.Angle  = Directions[i];
                Minutiae[i] = temp;
            }
            var path1 = Path.GetTempPath() + "binaryImage.png";

            ImageHelper.SaveArray(binaryImage, path1);
            var path2 = Path.GetTempPath() + "checkYourself.png";

            ImageHelper.MarkMinutiaeWithDirections(path1, Minutiae, path2);
            Process.Start(path2);
        }
Пример #15
0
        public static double[,] BinarizeImage(double[,] image, int rows, int columns)
        {
            var newImage = ImageEnhancementHelper.EnhanceImage(image);

            return(GlobalBinarization.Binarization(newImage, Constants.BinarizationThreshold));
        }