public void CreatTemplateTest()
        {
            /* double[,] img1 = ImageHelper.LoadImage<double>(Resources._1_1);
             double[,] img2 = ImageHelper.LoadImage<double>(Resources._1_2*/
            double[,] imgDoubles = ImageHelper.LoadImage<double>(Resources._1_1);

            imgDoubles.DoNormalization(100, 100);

            int[,] imgInts = imgDoubles.Select2D((x => (int)x));
            OrientationField orf = new OrientationField(imgInts, 16);
            double[,] orient = orf.GetOrientationMatrix(imgInts.GetLength(0), imgInts.GetLength(1));

            var freqMatrx = LocalRidgeFrequency.GetFrequencies(imgDoubles, orient);

            var res = ImageEnhancement.Enhance(imgDoubles, orient, freqMatrx, 32, 8);

               /* var img = ImageHelper.LoadImage<int>(Resources._1_1);

            int h = img.GetLength(0);
            int w = img.GetLength(1);

            int[] withoutHolesAndIslands = HolesAndIslandsResolver.ResolveHolesAndIslands(
                Array2Dto1D(ImageProcessing.Binarization.ImageBinarization.Binarize2D(img, 128)),
                16,
                9,
                w, h);*/
        }
예제 #2
0
        public static void SaveToFile(this OrientationField field, string name, bool openFileAfterSaving = false)
        {
            var bmp = SaveToBitmap(field);

            bmp.Save(name, ImageHelper.GetImageFormatFromExtension(name));
            if (openFileAfterSaving)
            {
                Process.Start(name);
            }
        }
예제 #3
0
 public static Bitmap SaveToBitmap(this OrientationField field)
 {
     using (var bmp = new Bitmap(field.Blocks.GetLength(1) * field.BlockSize, field.Blocks.GetLength(0) * field.BlockSize))
     {
         var gfx = Graphics.FromImage(bmp);
         gfx.FillRectangle(Brushes.White, new Rectangle(0, 0, bmp.Width, bmp.Height));
         gfx.Save();
         return(SaveAboveToBitmap(field, bmp));
     }
 }
예제 #4
0
        public static double[,] CreatTemplateTest(double[,] imgDoubles)
        {
            imgDoubles.DoNormalization(100, 100);

            int[,] imgInts = imgDoubles.Select2D((x => (int)x));
            OrientationField orf = new OrientationField(imgInts, 16);
            double[,] orient = orf.GetOrientationMatrix(imgInts.GetLength(0), imgInts.GetLength(1));

            var freqMatrx = LocalRidgeFrequency.GetFrequencies(imgDoubles, orient);

            var res = ImageEnhancement.Enhance(imgDoubles, orient, freqMatrx, 32, 8);

            return ImageBinarization.Binarize2D(res, 128);
        }
        public void ImageEnhancmentTest()
        {
            var bmp = Resources.SampleFinger;
            double[,] imgDoubles = ImageHelper.LoadImage<double>(bmp);

            imgDoubles.DoNormalization(100, 100);

            int[,] imgInts = imgDoubles.Select2D((x => (int)x));
            OrientationField orf = new OrientationField(imgInts, 16);
            double[,] orient = orf.GetOrientationMatrix(imgInts.GetLength(0), imgInts.GetLength(1));

            var freqMatrx = LocalRidgeFrequency.GetFrequencies(imgDoubles, orient);

            var res = ImageEnhancement.Enhance(imgDoubles, orient, freqMatrx, 32, 8);
            var bmp2 = ImageHelper.SaveArrayToBitmap(res);
            bmp2.Save("001.bmp", ImageHelper.GetImageFormatFromExtension("009.bmp"));
        }
예제 #6
0
 public static void SaveToFile(this OrientationField field)
 {
     SaveToFile(field, ImageHelper.GetTemporaryImageFileName(), true);
 }
예제 #7
0
 // a shorter method to be used in tests
 public static void SaveAboveToFile(this OrientationField field, Bitmap undercoat)
 {
     SaveAboveToFile(field, undercoat, ImageHelper.GetTemporaryImageFileName(), true);
 }
        public static int[] ProjectionX(int xCentre, int yCentre, int[,] arr)
        {
            int fieldSizey = FieldSizex/2;
            int[] projX = new int[FieldSizex];
            OrientationField img = new OrientationField(arr);
            var angleOfX = img.GetOrientation(xCentre, yCentre) - Math.PI/2.0;
            Point tmpPoint;
            double angleSin = Math.Sin(angleOfX);
            double angleCos = Math.Cos(angleOfX);
            for (int i = -FieldSizex/2; i < FieldSizex/2; i++)
            {
                projX[i + FieldSizex/2] = 255;
                for (int j = -fieldSizey/2; j < fieldSizey/2; j++) // find the darkest
                {
                    double localSegment = Math.Sqrt(i*i + j*j);
                    if (Math.Abs(localSegment) > 0.000001)  //  double tolerance
                    {

                        angleSin = Math.Sin(angleOfX + Math.Asin(find_sin(1.0, 0.0, i, j)));
                        angleCos = Math.Cos(angleOfX + Math.Acos(find_cos(1.0, 0.0, i, j)));
                        tmpPoint = Turn(0, (int) Math.Round(localSegment), 0, 0, angleCos, angleSin);
                    }
                    else
                    {
                        tmpPoint.X = 0;
                        tmpPoint.Y = 0;
                    }

                    if (tmpPoint.X + xCentre < 0 || tmpPoint.X + xCentre >= arr.GetLength(0) || tmpPoint.Y + yCentre < 0 ||
                        tmpPoint.Y + yCentre >= arr.GetLength(1))
                    {
                        continue;
                    }

                    if (projX[i + FieldSizex/2] >= arr[tmpPoint.X + xCentre, tmpPoint.Y + yCentre])
                    {
                        projX[i + FieldSizex/2] = arr[tmpPoint.X + xCentre, tmpPoint.Y + yCentre];
                    }

                }
            }
            return projX;
        }