コード例 #1
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);
        }
コード例 #2
0
        public void ExperimentMethod()
        {
            double[,] img1 = ImageHelper.LoadImage(Resources._104_6);
            int[,] resultImg1;

            resultImg1 = Segmentator.Segmetator(img1, windowSize, weight, threshold).Select2D(x => x > 0 ? 255 : 0);
            ImageHelper.SaveIntArray(resultImg1, Path.GetTempPath() + "Segm_104_6" + ".png");
        }
コード例 #3
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);
        }
コード例 #4
0
        public float[] SegmentImage(float[] image, int rows, int columns, out int[,] mask, bool useCuda = false)
        {
            if (useCuda)
            {
                var maskRows       = (int)Math.Ceiling((double)rows / Constants.SegmentationWindowSize);
                var maskColumns    = (int)Math.Ceiling((double)columns / Constants.SegmentationWindowSize);
                var maskLinearized = new int[maskRows * maskColumns];

                var sw = new Stopwatch();
                sw.Start();
                CUDASegmentator(image, columns, rows,
                                (float)Constants.SegmentationWeight, Constants.SegmentationWindowSize, maskLinearized, maskColumns, maskRows);
                sw.Stop();
                mask = maskLinearized.Make2D(maskRows, maskColumns);

                Segmentator.PostProcessing(mask, Constants.SegmentationThreshold);

                var bigMask = Segmentator.GetBigMask(mask, rows, columns,
                                                     Constants.SegmentationWindowSize);

                // we discard border regions in order to not catch minutiae there
                var oldMask = mask;
                mask = oldMask.Select2D((x, row, column) =>
                {
                    if (x == 0)
                    {
                        return(0);
                    }
                    if (row > 0)
                    {
                        if (oldMask[row - 1, column] == 0)
                        {
                            return(0);
                        }
                        if (column > 0)
                        {
                            if (oldMask[row - 1, column - 1] == 0)
                            {
                                return(0);
                            }
                        }
                        if (column < maskColumns - 1)
                        {
                            if (oldMask[row - 1, column + 1] == 0)
                            {
                                return(0);
                            }
                        }
                        if (row < maskRows - 1)
                        {
                            if (oldMask[row + 1, column] == 0)
                            {
                                return(0);
                            }
                            if (column > 0)
                            {
                                if (oldMask[row + 1, column - 1] == 0)
                                {
                                    return(0);
                                }
                            }
                            if (column < maskColumns - 1)
                            {
                                if (oldMask[row + 1, column + 1] == 0)
                                {
                                    return(0);
                                }
                            }
                        }
                    }
                    if (column > 0)
                    {
                        if (oldMask[row, column - 1] == 0)
                        {
                            return(0);
                        }
                    }
                    if (column < maskColumns - 1)
                    {
                        if (oldMask[row, column + 1] == 0)
                        {
                            return(0);
                        }
                    }
                    return(1);
                });


                return(Segmentator.ColorImage(image, rows, columns, bigMask));
            }
            mask = Segmentator.Segmetator(image.Make2D(rows, columns).Select2D(x => (double)x),
                                          Constants.SegmentationWindowSize, Constants.SegmentationWeight,
                                          Constants.SegmentationThreshold);
            return(Segmentator.ColorImage(image.Make2D(rows, columns).Select2D(x => (double)x),
                                          Segmentator.GetBigMask(mask, image.GetLength(0), image.GetLength(1),
                                                                 Constants.SegmentationWindowSize)).Make1D().Select(x => (float)x).ToArray());
        }
コード例 #5
0
 public static double[,] SegmentImage(double[,] image, int rows, int columns, out int[,] mask)
 {
     mask = Segmentator.Segmetator(image, Constants.SegmentationWindowSize, Constants.SegmentationWeight, Constants.SegmentationThreshold);
     return(Segmentator.ColorImage(image, Segmentator.GetBigMask(mask, image.GetLength(0), image.GetLength(1), Constants.SegmentationWindowSize)));
 }