Exemple #1
0
        public static void GaborFilter(Bitmap b, float gamma, float lambda, float psi, float sigma, float theta)
        {
            GaborFilter gb     = new GaborFilter();
            Random      random = new Random();
            Bitmap      bx;



            gb.Gamma  = gamma;
            gb.Lambda = lambda;
            gb.Psi    = psi;
            gb.Sigma  = sigma;

            gb.Theta = theta;
            bx       = ImageSupporter.ColorToGrayscale((Bitmap)b.Clone());


            Bitmap tmp = bx;

            tmp = gb.Apply(bx);

            ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(tmp));

            iw.Title = gb.Gamma + " " + gb.Lambda + " " + gb.Psi + " " + gb.Sigma + " " + gb.Theta;
            iw.Show();
        }
        void Form1_DragDrop(object sender, DragEventArgs e)
        {
            String[] files = (String[])e.Data.GetData(DataFormats.FileDrop);
            // foreach (string file in files) Console.WriteLine(file);
            //this.TXT.Text = files[0];
            Bitmap bitmap = new Bitmap(files[0]);

            BitmapImage logo = new BitmapImage();

            logo.BeginInit();
            logo.UriSource = new Uri(files[0]);
            logo.EndInit(); // Getting the exception here
            originalImage.Source = logo;

            Bitmap tmp = ImageSupporter.ColorToGrayscale(ImageSupporter.BitmapImage2Bitmap(logo));
            Bitmap or  = Filtrator.segmentation(100, tmp);

            //originalImage.Source = ImageSupporter.Bitmap2BitmapImage(ImageSupporter.ColorToGrayscale(ImageSupporter.BitmapImage2Bitmap(logo)));
            originalImage.Source = ImageSupporter.Bitmap2BitmapImage(or);
            newImageSource       = files[0];


            fingerprint        = new Fingerprint((BitmapImage)originalImage.Source);
            this.orginalBitmap = fingerprint.orginalImage;
            this.workingImage  = (Bitmap)orginalBitmap.Clone();

            //actualFingerprint = new Fingerprint(logo);
            helpText.Visibility = Visibility.Hidden;
        }
        public ImageCell getCell(System.Windows.Controls.Image image, int x, int y)
        {
            int number  = bitmap.Width / cellSize;
            int numberH = bitmap.Height / cellSize;


            Random random = new Random();
            int    i      = x;
            int    j      = y;

            for (int a = 0; a < cellTab[i, j].bitmap.Width; a++)
            {
                for (int b = 0; b < cellTab[i, j].bitmap.Height; b++)
                {
                    byte bit = bitmap.GetPixel(a + i * 16, b + j * 16).R;
                    if (bit + 122 < 255)
                    {
                        bitmap.SetPixel(a + i * 16, b + j * 16, Color.FromArgb(bit + 122, bit, bit));
                    }
                    else
                    {
                        bitmap.SetPixel(a + i * 16, b + j * 16, Color.FromArgb(bit - 122, bit, bit));
                    }
                }
            }

            ImageSupporter.matchArea(image, i * 16, j * 16, 16, 16);



            return(cellTab[i, j]);
        }
Exemple #4
0
        public Bitmap gaborFilter(Bitmap b, float gamma, float lambda, float psi, float sigma, float theta)
        {
            GaborFilter filter = new GaborFilter();
            Random      random = new Random();
            Boolean     flaga  = true;



            filter.Gamma  = gamma;
            filter.Lambda = lambda;
            filter.Psi    = psi;
            filter.Sigma  = sigma;
            filter.Theta  = theta;

            Bitmap bx = ImageSupporter.ColorToGrayscale(b);

            var okno = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(filter.Apply(ImageSupporter.ColorToGrayscale(bx))));

            okno.Title = filter.Gamma + " " + filter.Lambda + " " + filter.Psi + " " + filter.Sigma + " " + filter.Theta;
            okno.Show();


            filter.Gamma = 3.0;
            filter.Theta = 0.0;
            GrayscaleToRGB grayscaleToRGB = new GrayscaleToRGB();

            return(grayscaleToRGB.Apply(filter.Apply(ImageSupporter.ColorToGrayscale(b))));
        }
Exemple #5
0
        public static Bitmap gaborFilter(Bitmap b, GaborFilter gf)
        {
            // Grayscale g = new Grayscale(0.2125, 0.7154, 0.0721);



            /*filter.Gamma = random.Next(1,5);
             * filter.Lambda=random.Next(1,5);
             * filter.Psi=random.Next(1,5);
             * filter.Sigma=random.Next(1,5);
             * filter.Theta=random.Next(1,5);*/

            Bitmap bx = ImageSupporter.ColorToGrayscale(b);

            gf.Apply(ImageSupporter.ColorToGrayscale(bx));
            //  var okno = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(filter.Apply(ImageSupporter.ColorToGrayscale(bx))));
            // okno.Title = filter.Gamma + " " + filter.Lambda + " " + filter.Psi + " " + filter.Sigma + " " + filter.Theta;
            // okno.Show();



            GrayscaleToRGB grayscaleToRGB = new GrayscaleToRGB();

            return(grayscaleToRGB.Apply(gf.Apply(ImageSupporter.ColorToGrayscale(b))));
        }
        private void LowPassFilter(object sender, RoutedEventArgs e)
        {
            temporary = Filtrator.LowPassFilter(JMask.GAUSS, (Bitmap)workingImage.Clone());
            ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(temporary));

            iw.Show();
        }
        private void Laplasjan(object sender, RoutedEventArgs e)
        {
            temporary = Filtrator.LaplasjanFilter((Bitmap)workingImage.Clone());
            ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(temporary));

            iw.Show();
        }
Exemple #8
0
        public static void gaborFilterRandom(Bitmap b)
        {
            GaborFilter gb     = new GaborFilter();
            Random      random = new Random();
            Bitmap      bx;



            for (int i = 1; i < 100; i++)
            {
                gb.Gamma  = random.NextDouble() * random.Next(1, 10);;
                gb.Lambda = random.Next(1, 10);
                gb.Psi    = random.NextDouble();
                gb.Sigma  = random.Next(1, 10);

                gb.Theta = 0;
                bx       = ImageSupporter.ColorToGrayscale(b);
                if (gb.Gamma == 0)
                {
                    gb.Gamma = 0.01;
                }
                Console.WriteLine(gb.Gamma + " " + gb.Lambda + " " + gb.Psi + " " + gb.Sigma + " " + gb.Theta);
                try
                {
                    ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(gb.Apply(bx)));
                    iw.Title = gb.Gamma + " " + gb.Lambda + " " + gb.Psi + " " + gb.Sigma + " " + gb.Theta;
                    iw.Show();
                }
                catch (Exception e)
                {
                    e.GetBaseException();
                }
            }
        }
        private void Gornoprzepustowy(object sender, RoutedEventArgs e)
        {
            temporary = Filtrator.HighPassFilter(EMask.Prewitt, (Bitmap)workingImage.Clone());
            ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(temporary));

            iw.Show();
        }
Exemple #10
0
        public Dictionary <Point, int> getSectionPixels(Point c, Bitmap orginal, int sectionLeng)
        {
            double angle = localDirectionMap.getDirectionForPixel(c.X, c.Y);

            angle = ImageSupporter.restrictAngle(angle);

            Point p = new Point((int)(c.X - Math.Sin(angle) * sectionLeng + 0.5), (int)(c.Y - Math.Cos(angle) * sectionLeng + 0.5));
            Point k = new Point((int)(c.X + Math.Sin(angle) * sectionLeng + 0.5), (int)(c.Y + Math.Cos(angle) * sectionLeng + 0.5));

            if (ImageSupporter.RadianToDegree(angle) > 80 && ImageSupporter.RadianToDegree(angle) < 100)
            {
                double ck = ImageSupporter.RadianToDegree(angle);
            }
            Dictionary <Point, int> section = new Dictionary <Point, int>();

            foreach (var item in ImageSupporter.EnumerateLineNoDiagonalSteps(p.X, p.Y, k.X, k.Y))
            {
                try
                {
                    section.Add(new Point(item.Item1, item.Item2), orginal.GetPixel(item.Item1, item.Item2).R);
                }
                catch (Exception e)
                {
                }
            }


            return(section);
        }
 //zmienia zadany kąt na kąt od 180 do 360
 public static double angletoIIIandIV(double angle)
 {
     if (ImageSupporter.DegreeToRadian(180) < angle && ImageSupporter.DegreeToRadian(180) > angle)
     {
         angle += ImageSupporter.DegreeToRadian(180);
     }
     return(angle);
 }
Exemple #12
0
        //metoda zrwacająca wynik filtru Cannyego
        public static Bitmap Canny(Bitmap bitmap)
        {
            Bitmap            temporary         = ImageSupporter.ColorToGrayscale(bitmap);;
            CannyEdgeDetector cannyEdgeDetector = new CannyEdgeDetector();

            temporary = cannyEdgeDetector.Apply((Bitmap)temporary.Clone());

            return(ImageSupporter.GrayScaleToColor(temporary));
        }
        private void Test(object sender, RoutedEventArgs e)
        {
            MinutiaWektor       wektor            = database.mBase[1].MinutiaesWektor;
            ModyficationElement przesuniecie      = new ModyficationElement(0, 0, 10);
            MinutiaWektor       przesunietyWektor = new MinutiaWektorComperer().MapMinutiaWektor(wektor, przesuniecie);
            Bitmap b = (Bitmap)orginalBitmap.Clone();

            b             = MatchMinuties(b, przesunietyWektor);
            QUATRE.Source = ImageSupporter.Bitmap2BitmapImage(b);
        }
Exemple #14
0
        private Minutia MapMinutia(Minutia m, ModyficationElement em)//działa poprawnie sprawdzone
        {
            //  em = new ModyficationElement(-10, 5, 30);
            double angle  = ImageSupporter.DegreeToRadian(em.angle);
            int    x      = (int)(Math.Cos(angle) * m.p.X - Math.Sin(angle) * m.p.Y + em.x + 0.5);
            int    y      = (int)(Math.Sin(angle) * m.p.X + Math.Cos(angle) * m.p.Y + em.y + 0.5);
            double angle2 = m.direction + angle;//tutaj nie jestem pewny z kontem

            return(new Minutia(new Point(x, y), angle2, m.kind));
        }
 //metody nieużywane do działąnia programu, ale istotne w trakcie testów i przygotowania pracy dyplomowej
 public void losowyObszar(object sender, EventArgs e)
 {
     fingerprint = new Fingerprint((BitmapImage)originalImage.Source);
     fingerprint.startRecognition(fingerprint.localOrientationMap);
     randomCel = fingerprint.getRandomCell(mapakierunkow);
     ImageSupporter.WriteBitmap(randomCel.bitmap);
     QUATRE.Source = ImageSupporter.Bitmap2BitmapImage(randomCel.bitmap);
     fingerprint.merge();
     threetothreeImage.Source = ImageSupporter.ToBitmapSource(ImageSupporter.Scale(1, fingerprint.localOrientationMap));
 }
Exemple #16
0
        public static Bitmap Binaryzation(Bitmap b, int limit)
        {
            Threshold th = new Threshold();

            th.ThresholdValue = limit;
            Bitmap bx = ImageSupporter.ColorToGrayscale((Bitmap)b.Clone());

            GrayscaleToRGB grayscaleToRGB = new GrayscaleToRGB();

            return(grayscaleToRGB.Apply(th.Apply(ImageSupporter.ColorToGrayscale(bx))));
        }
 private void ShowOK(object sender, RoutedEventArgs e)
 {
     try
     {
         this.workingImage      = (Bitmap)temporary.Clone();
         odszumionyObraz.Source = ImageSupporter.Bitmap2BitmapImage(workingImage);
     }
     catch (Exception ex)
     {
     }
 }
Exemple #18
0
        public static Bitmap GaborFilter(Bitmap b, float angle)
        {
            Bitmap      bz       = (Bitmap)b.Clone();
            GaborBank   gb       = new GaborBank();
            GaborFilter gf       = gb.GetGaborFilterFromBank(angle);
            Bitmap      bx       = ImageSupporter.ColorToGrayscale((Bitmap)bz.Clone());
            Bitmap      filtered = gf.Apply(bx);


            return(ImageSupporter.GrayScaleToColor(filtered));
        }
 private void Cancel(object sender, RoutedEventArgs e)
 {
     try
     {
         temporary              = (Bitmap)orginalBitmap.Clone();
         workingImage           = (Bitmap)orginalBitmap.Clone();
         odszumionyObraz.Source = ImageSupporter.Bitmap2BitmapImage(workingImage);
     }
     catch (Exception ex)
     {
     }
 }
        private void AddImageToDatabase(String text)
        {
            String name = text;

            try
            {
                ImageSupporter.Save(ImageSupporter.Bitmap2BitmapImage(orginalBitmap), Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\database\\" + name + ".png");
            }
            catch (Exception ex)
            {
            }
        }
Exemple #21
0
        public double ddd(double angleNew, double angleOld)
        {
            if (Math.Abs(angleNew - angleOld) < ImageSupporter.DegreeToRadian(360) - Math.Abs(angleNew - angleOld))
            {
                return(angleNew - angleOld);
            }
            else
            {
                return(ImageSupporter.DegreeToRadian(360) - Math.Abs(angleNew - angleOld));
            }

            //return Math.Min(Math.Abs(angleNew - angleOld), ImageSupporter.DegreeToRadian(360) - Math.Abs(angleNew - angleOld));
        }
        private void MinutaesDetection(object sender, RoutedEventArgs e)
        {
            QUATRE.Source = ImageSupporter.Bitmap2BitmapImage(fingerprint.getSectionPoints((Bitmap)workingImage.Clone()));

            Tuple <Bitmap, Bitmap> alreadyPassedImages = fingerprint.getAlreadyPassed();

            pojedynczyKierunek.Source    = ImageSupporter.Bitmap2BitmapImage(alreadyPassedImages.Item2);
            threetothreeImage.Source     = ImageSupporter.Bitmap2BitmapImage(alreadyPassedImages.Item1);
            temporaryMinutiasMap         = new MinutiaWektor(fingerprint.GetTemporaryMinutiasMap());
            MinuteaWektorInformator.Text = "Wykryto " + temporaryMinutiasMap.m.Count() + " minucji \n" +
                                           +temporaryMinutiasMap.GetEndCount() + " zakończeń \n" +
                                           +temporaryMinutiasMap.GetForkCount() + " rozwidleń";
        }
        private void ShowChosenFingerprint(object sender, RoutedEventArgs e)
        {
            int index = DatabaseList.Items.IndexOf(sender);

            chossenDatabaseElement = index;
            DatabaseElement chosen = databaseList[index];

            Bitmap b = ImageSupporter.BitmapImage2Bitmap(new BitmapImage(new Uri(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\database\\" + chosen.FingerprntName + ".png")));

            MinutiaWektor zbazy = database.mBase[index].MinutiaesWektor;

            b             = MatchMinuties2(b, zbazy, Color.Blue, Color.Orange);
            QUATRE.Source = ImageSupporter.Bitmap2BitmapImage(b);
        }
 private void Q(object sender, RoutedEventArgs e)
 {
     try
     {
         //randomCel.toDirectionMap();
         //pojedynczyKierunek.Source = ImageSupporter.Bitmap2BitmapImage(randomCel.bitmap);
         //  pojedynczyKierunek.Source = ImageSupporter.Bitmap2BitmapImage(randomCel.toDirectionMapTest());
         pojedynczyKierunek.Source = ImageSupporter.ToBitmapSource(ImageSupporter.Scale(100, randomCel.toDirectionMapTest()));
     }
     catch (System.NullReferenceException en)
     {
         Console.WriteLine("Nie masz wylosowanej komórki");
     }
 }
        public void MapaKierunkow(object sender, RoutedEventArgs e)
        {
            // mapakierunkow.Source = ImageSupporter.Bitmap2BitmapImage(actualFingerprint.returnGrey());
            try
            {
                // fingerprint.startRecognition(fingerprint.localOrientationMap);
                fingerprint.startRecognition((Bitmap)workingImage.Clone());
                fingerprint.toDirectionMask();

                mapakierunkow.Source = ImageSupporter.Bitmap2BitmapImage(fingerprint.localOrientationMap);
            }
            catch (InvalidCastException ex)
            {
                Console.WriteLine("Nie podałeś odcisku palca do analizy");
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Boolean flaga = true;

            while (flaga)
            {
                Random random = new Random();
                int    i      = random.Next();

                if (!File.Exists(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\screens\\" + i + ".png"))
                {
                    ImageSupporter.Save((BitmapImage)obrazek.Source, Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\screens\\" + i + ".png");
                    flaga = false;
                }
            }
        }
Exemple #27
0
        public Bitmap GetImageWithMatchedMinutias()
        {
            getSectionPointsBitmap(orginalBitmap);
            this.alreadyPassedInverted = (Bitmap)alreadyPassed.Clone();
            this.alreadyPassed         = (Bitmap)orginalBitmap.Clone();
            this.orginalBitmap         = ImageSupporter.ReverseBitmap(orginalBitmap);
            ImageWindow iw = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(training));

            iw.Show();
            this.training = (Bitmap)orginalBitmap.Clone();
            this.inverted = true;
            getSectionPointsBitmap(orginalBitmap);
            this.orginalBitmap = ImageSupporter.ReverseBitmap(orginalBitmap);
            getMinutionsMap();//tutaj jest sprawdzanie i usuwanie niewłaściwych minucji
            this.inverted = false;
            return(MatchMunities());
        }
Exemple #28
0
        public List <Tuple <DatabaseElement, int, ModyficationElement, int> > CheckList(MinutiaWektor wektor)
        {
            List <Tuple <DatabaseElement, int, ModyficationElement, int> > result = new List <Tuple <DatabaseElement, int, ModyficationElement, int> >();
            MinutiaWektorComperer comperer = new MinutiaWektorComperer(10, 10, ImageSupporter.DegreeToRadian(15));

            foreach (var item in mBase)
            {
                Tuple <bool, int, ModyficationElement, int> compereResult = comperer.Compere(item.MinutiaesWektor, wektor);

                if (compereResult.Item1)
                {
                    result.Add(new Tuple <DatabaseElement, int, ModyficationElement, int>(item, compereResult.Item2, compereResult.Item3, compereResult.Item4));
                }
            }



            return(result);
        }
        private void ListBox_DoubleClick(object sender, RoutedEventArgs e)
        {
            int                 index        = EqualFingerprintList.Items.IndexOf(sender);
            DatabaseElement     chosen       = equals[index].Item1;
            ModyficationElement przesuniecie = equals[index].Item3;
            MinutiaWektor       wektor       = temporaryMinutiasMap;

            MinutiaWektor przesunietyWektor = new MinutiaWektorComperer().MapMinutiaWektor(temporaryMinutiasMap, przesuniecie);

            Bitmap b = ImageSupporter.BitmapImage2Bitmap(new BitmapImage(new Uri(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\database\\" + chosen.FingerprntName + ".png")));

            b = MatchMinuties2(b, przesunietyWektor, Color.Green, Color.Green);
            MinutiaWektor zbazy = database.mBase[index].MinutiaesWektor;

            b = MatchMinuties2(b, zbazy, Color.Blue, Color.Blue);
            b = MatchMinuties2(b, temporaryMinutiasMap, Color.Orange, Color.Orange);

            QUATRE.Source = ImageSupporter.Bitmap2BitmapImage(b);
        }
        private Bitmap MatchMinuties2(Bitmap bitmap, MinutiaWektor wektor, Color zakocznczenia, Color rozwidlenia)
        {
            Bitmap final = (Bitmap)bitmap.Clone();

            foreach (var p in wektor.m)
            {
                for (int i = p.p.X - 1; i < p.p.X + 1; i++)
                {
                    for (int j = p.p.Y - 1; j < p.p.Y + 1; j++)
                    {
                        if (i < final.Width && i > 0 && j < final.Height && j > 0)
                        {
                            ImageSupporter.MatchMinutia2(final, zakocznczenia, rozwidlenia, p);
                        }
                    }
                }
            }
            return(final);
        }