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 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)))); }
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(); } } }
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(); }
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)))); }
//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)); }
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)))); }
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)); }
//metoda zwracająca bank filtrów gabora dla zadanej bitmapy public static List <Bitmap> gaborFilterMyBank(Bitmap bs) { List <SetValuesForGabor> bank = new List <SetValuesForGabor>(); bank.Add(new SetValuesForGabor(4, 8, 0.5f, 9.2f, 0)); bank.Add(new SetValuesForGabor(4, 8, 0.5f, 4.8f, (float)ImageSupporter.DegreeToRadian(15))); bank.Add(new SetValuesForGabor(4, 6.5f, 0.5f, 4.3f, (float)ImageSupporter.DegreeToRadian(30))); bank.Add(new SetValuesForGabor(4, 7, 0.5f, 4.3f, (float)ImageSupporter.DegreeToRadian(45))); bank.Add(new SetValuesForGabor(4, 6.5f, 0.5f, 4.3f, (float)ImageSupporter.DegreeToRadian(60))); bank.Add(new SetValuesForGabor(4, 8, 0.5f, 4.8f, (float)ImageSupporter.DegreeToRadian(75))); bank.Add(new SetValuesForGabor(4, 7, 0.5f, 4.6f, (float)ImageSupporter.DegreeToRadian(90))); bank.Add(new SetValuesForGabor(4, 7.3f, 0.5f, 4.4f, (float)ImageSupporter.DegreeToRadian(105))); bank.Add(new SetValuesForGabor(4, 6.2f, 0.5f, 3.7f, (float)ImageSupporter.DegreeToRadian(120))); bank.Add(new SetValuesForGabor(4, 7, 0.5f, 4.3f, (float)ImageSupporter.DegreeToRadian(135))); bank.Add(new SetValuesForGabor(4, 6.5f, 0.5f, 4.3f, (float)ImageSupporter.DegreeToRadian(150))); bank.Add(new SetValuesForGabor(4, 8, 0.5f, 4.8f, (float)ImageSupporter.DegreeToRadian(165))); GaborFilter gb = new GaborFilter(); Random random = new Random(); Bitmap bx; Bitmap b = (Bitmap)bs.Clone(); List <Bitmap> gaborBank = new List <Bitmap>(); bx = ImageSupporter.ColorToGrayscale(b); for (int i = 0; i < bank.Count; i++) { bank[i].SetGaborFilter(gb); gaborBank.Add(gb.Apply((Bitmap)bx.Clone())); ImageWindow im = new ImageWindow(ImageSupporter.Bitmap2BitmapImage(gaborBank[i])); im.Title = gb.Gamma + " " + gb.Lambda + " " + gb.Psi + " " + gb.Sigma + " " + gb.Theta; im.Show(); } return(gaborBank); }
private void LoadImage(String path) { BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri(path); logo.EndInit(); //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 = path; fingerprint = new Fingerprint(ImageSupporter.Bitmap2BitmapImage(or)); this.orginalBitmap = fingerprint.orginalImage; this.workingImage = (Bitmap)orginalBitmap.Clone(); }
public static Bitmap gaborFilter(Bitmap b, float gamma, float lambda, float psi, float sigma, float theta) { // Grayscale g = new Grayscale(0.2125, 0.7154, 0.0721); 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; /*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); filter.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(filter.Apply(ImageSupporter.ColorToGrayscale(b)))); }
//konwertowanie do 8 bitowego obrazu w odcieniu szarości public static Bitmap GrayScaleToColor(Bitmap bitmap) { GrayscaleToRGB grayscaleToRGB = new GrayscaleToRGB(); return(grayscaleToRGB.Apply(ImageSupporter.ColorToGrayscale(bitmap))); }