コード例 #1
0
        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);
        }
コード例 #2
0
        //public List<Minutia> FilterMinutiae(List<Minutia> result, int[,] segment)
        //{
        //    var size = Constants.SegmentationWindowSize;

        //    var maxX = segment.GetLength(0);
        //    var maxY = segment.GetLength(1);

        //    var output = new List<Minutia>();

        //    foreach (var minutia in result)
        //    {
        //        var y = minutia.X/size;
        //        var x = minutia.Y/size;

        //        try
        //        {
        //            if (segment[x, y] == 1)
        //            {

        //                if (x > 0)
        //                {
        //                    if (segment[x - 1, y] == 0) continue;
        //                    if (y > 0) if (segment[x - 1, y - 1] == 0) continue;
        //                    if (y < maxY) if (segment[x - 1, y + 1] == 0) continue;
        //                }
        //                if (x < maxX)
        //                {
        //                    if (segment[x + 1, y] == 0) continue;
        //                    if (y > 0) if (segment[x + 1, y - 1] == 0) continue;
        //                    if (y < maxY) if (segment[x + 1, y + 1] == 0) continue;
        //                }
        //                if (y > 0)
        //                {
        //                    if (segment[x, y - 1] == 0) continue;
        //                }
        //                if (y < maxY)
        //                {
        //                    if (segment[x, y + 1] == 0) continue;
        //                }

        //                output.Add(minutia);
        //            }
        //        }
        //        catch (Exception)
        //        {

        //            throw;
        //        }

        //    }

        //    return output;
        //}
        public List <Minutia> FindMinutiae(float[] result, int rows, int columns, float[] orField, int orFieldRows, int orFieldColumns, int[,] mask)
        {
            var startImg  = result.Make2D(rows, columns).Select2D(x => (double)x);
            var orField2D = orField.Make2D(orFieldRows, orFieldColumns).Select2D(x => (double)x);

            var minutiae = MinutiaeDetection.FindMinutiae(startImg);
            //--------------------------------
            var trueMinutiae = new List <Minutia>();

            for (int i = 0; i < minutiae.Count; i++)
            {
                if (mask[minutiae[i].Y / Constants.SegmentationWindowSize, minutiae[i].X / Constants.SegmentationWindowSize] != 0)
                {
                    trueMinutiae.Add(minutiae[i]);
                }
            }
            minutiae = trueMinutiae;

            //--------------------------------
            minutiae = MinutiaeDetection.FindBigMinutiae(minutiae);

            MinutiaeDirection.FindDirection(orField2D.Select2D(x => Math.PI - x),
                                            Constants.OrFieldWindowSize - Constants.OrFieldOverlap, minutiae,
                                            startImg.Select2D(x => (int)x), 4);

            return(minutiae);
        }
コード例 #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
        public void TestMethod4()
        {
            //var img = ImageHelper.LoadImage(TestResource._104_6);
            var img  = ImageHelper.LoadImage(TestResource.MinutiaeBigTest);
            var path = Path.GetTempPath() + "detection.png";

            ImageHelper.MarkMinutiae(TestResource.MinutiaeBigTest, MinutiaeDetection.FindBigMinutiae(MinutiaeDetection.FindMinutiae(img)), path);
            //Trace.WriteLine(MinutiaeDetection.FindMinutiae(img));
            //ImageHelper.SaveArray(Detection, path);
            Process.Start(path);
        }
コード例 #5
0
        public static List <CUDAFingerprinting.Common.Minutia> FindMinutiae(double[,] startImg, int rows, int columns, double[,] orField2D, int orFieldRows, int orFieldColumns, int[,] mask)
        {
            var minutiae = MinutiaeDetection.FindMinutiae(startImg);
            //--------------------------------
            var trueMinutiae = new List <CUDAFingerprinting.Common.Minutia>();

            for (int i = 0; i < minutiae.Count; i++)
            {
                if (mask[minutiae[i].Y / Constants.SegmentationWindowSize, minutiae[i].X / Constants.SegmentationWindowSize] != 0)
                {
                    trueMinutiae.Add(minutiae[i]);
                }
            }
            minutiae = trueMinutiae;

            //--------------------------------
            minutiae = MinutiaeDetection.FindBigMinutiae(minutiae);

            MinutiaeDirection.FindDirection(orField2D.Select2D(x => Math.PI - x),
                                            Constants.OrFieldWindowSize - Constants.OrFieldOverlap, minutiae,
                                            startImg.Select2D(x => (int)x), 4);

            return(minutiae);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
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);
        }