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); }
private void followingDown(Point m) { double angle = localDirectionMap.getDirectionForPixel(m.X, m.Y); angle = ImageSupporter.angletoIIIandIV(angle); Point n = new Point((int)(m.X - Math.Cos(angle) * dlugoscSkoku + 0.5), (int)(m.Y + Math.Sin(angle) * dlugoscSkoku + 0.5)); if (n.X < training.Width && n.X > 0 && n.Y > 0 && n.Y < training.Height) { //if (orginalBitmap.GetPixel(n.X, n.Y).R < limit && alreadyPassed.GetPixel(n.X, n.Y).B!=128) //{ Dictionary <Point, int> sectionLine = getSectionPixels(n, orginalBitmap, startingSectionLen); foreach (var item in sectionLine) { training.SetPixel(item.Key.X, item.Key.Y, Color.Red); } Point p = sectionMinimum(sectionLine, alreadyPassed); List <Point> points = ImageSupporter.GetLine(m, p); bool flag = true; foreach (var item in points) { if (orginalBitmap.GetPixel(item.X, item.Y).R > limit) { flag = false; } } if (/*orginalBitmap.GetPixel(p.X, p.Y).R< limit*/ flag && alreadyPassed.GetPixel(p.X, p.Y).B != 128) //if (orginalBitmap.GetPixel(p.X, p.Y).R < limit && alreadyPassed.GetPixel(p.X, p.Y).B != 128) { for (int a = p.X - 1; a < p.X + 2; a++) { for (int b = p.Y - 1; b < p.Y + 2; b++) { try { // if(a<training.Width&&a>0&&b<training.Height&&b>0) // training.SetPixel(a, b, Color.Blue); } catch (Exception e) { } } } ImageSupporter.matchLine2(alreadyPassed, m, n, standard, 5); ImageSupporter.matchLine2(training, m, n, Color.Pink, 1); if (ImageSupporter.RadianToDegree( Math.Abs( localDirectionMap .getDirectionForPixel(p.X, p.Y) - localDirectionMap.getDirectionForPixel(m.X, m.Y))) > 100) { followingUp(p); } else { followingDown(p); } } else if (alreadyPassed.GetPixel(p.X, p.Y).B == 128 && flag) { List <Point> list = ImageSupporter.GetLine(m, n); Point wsk = p; foreach (Point pi in list) { wsk = pi; int i = orginalBitmap.GetPixel(pi.X, pi.Y).R; if (orginalBitmap.GetPixel(pi.X, pi.Y).B != 128) { } else { break; } } // minucje.Add(new Tuple<Point,double>(wsk, angle)); try { for (int a = wsk.X - 1; a < wsk.X + 2; a++) { for (int b = wsk.Y - 1; b < wsk.Y + 2; b++) { // training.SetPixel(a, b, Color.Yellow); } } //int i = orginalBitmap.GetPixel(wsk.X, wsk.Y).R; //training.SetPixel(wsk.X, wsk.Y, Color.Orange); } catch (Exception ec) { } } // else if(orginalBitmap.GetPixel(p.X, p.Y).R >= limit) else //if( !flag&& alreadyPassed.GetPixel(p.X, p.Y).B != 128) { // training.SetPixel(n.X, n.Y, Color.Orange); List <Point> list = ImageSupporter.GetLine(m, n); Point wsk = n; foreach (Point pi in list) { // int i = orginalBitmap.GetPixel(pi.X, pi.Y).R; if (orginalBitmap.GetPixel(pi.X, pi.Y).R < limit) { } else { wsk = pi; break; } } Minutia newMinutia; if (!inverted) { newMinutia = new Minutia(wsk, angle, KindOfMinutia.ZAKONCZENIE); } else { newMinutia = new Minutia(wsk, angle, KindOfMinutia.ROZWIDLENIE); } minucje.Add(newMinutia); ImageSupporter.MatchMinutia2(training, Color.Orange, Color.Purple, newMinutia); try { for (int a = wsk.X - 1; a < wsk.X + 2; a++) { for (int b = wsk.Y - 1; b < wsk.Y + 2; b++) { // training.SetPixel(a, b, Color.Orange); } } //int i = orginalBitmap.GetPixel(wsk.X, wsk.Y).R; //training.SetPixel(wsk.X, wsk.Y, Color.Orange); } catch (Exception ec) { } } } }