Beispiel #1
0
        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);*/
        }
Beispiel #2
0
        public void SolveSecondPuzzle()
        {
            var sut = new ImageEnhancement(REAL_INPUT);

            sut.Enhance(50);

            Assert.Equal(18732, sut.CountLitPixels());
        }
Beispiel #3
0
        public void CountLitPixelsInSampleImage_WhenEnhancing50Times()
        {
            var sut = new ImageEnhancement(SAMPLE_INPUT);

            sut.Enhance(50);

            Assert.Equal(3351, sut.CountLitPixels());
        }
Beispiel #4
0
        public void SolveFirstPuzzle()
        {
            var sut = new ImageEnhancement(REAL_INPUT);

            sut.Enhance(2);

            Assert.Equal(5483, sut.CountLitPixels());
        }
Beispiel #5
0
        public void CountLitPixelsInSampleImage_WhenEnhancingTwice()
        {
            var sut = new ImageEnhancement(SAMPLE_INPUT);

            sut.Enhance(2);

            Assert.Equal(35, sut.CountLitPixels());
        }
Beispiel #6
0
        public void EnhanceImageCorrectly_WhenOneEnhancementIsApplied()
        {
            var sut = new ImageEnhancement(SAMPLE_INPUT);

            sut.Enhance(1);

            Assert.Equal(@".##.##.
#..#.#.
##.#..#
####..#
.#..##.
..##..#
...#.#.", sut.GetOutputImage());
        }
Beispiel #7
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"));
        }