Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. public void wykrycieWzorca2(Bitmap obrazek)
  2. {
  3. int licznikWObszarze = 0;
  4. for (int i = 0; i < obrazek.Width; i++)
  5. {
  6. for (int j = 0; j < obrazek.Height; j++)
  7. {
  8. Color Kolor = obrazek.GetPixel(i, j);
  9. if ((Kolor.R > 250) && (Kolor.G > 150) && (Kolor.B > 35))
  10. {
  11. Point Piksel = new Point(i, j);
  12. if (spelniajaceZalozenia2.Contains(Piksel) == false)
  13. {
  14. licznikWObszarze++;
  15. spelniajaceZalozenia2.Add(Piksel);
  16. for (int ObszarY = (i - 15); ObszarY < (i + 15); ObszarY++)
  17. {
  18. for (int ObszarX = (j - 15); ObszarX < (j + 15); ObszarX++)
  19. {
  20. Color Kolor2 = obrazek.GetPixel(ObszarY, ObszarX);
  21. if ((Kolor2.R > 250) && (Kolor2.G > 150) && (Kolor2.B > 35))
  22. {
  23. Point Piksel2 = new Point(ObszarY, ObszarX);
  24. if (spelniajaceZalozenia2.Contains(Piksel2) == false)
  25. {
  26. spelniajaceZalozenia2.Add(Piksel2);
  27. licznikWObszarze++;
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }
  34.  
  35. if (licznikWObszarze < 20)
  36. {
  37. spelniajaceZalozenia2.RemoveRange((spelniajaceZalozenia2.Count() - licznikWObszarze), licznikWObszarze);
  38. }
  39. licznikWObszarze = 0;
  40. }
  41. }
  42. foreach (Point piksel in spelniajaceZalozenia2)
  43. {
  44. obrazek.SetPixel(piksel.X, piksel.Y, Color.Black);
  45. }
  46. MessageBox.Show("ilosc piksli " + spelniajaceZalozenia2.Count().ToString());
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement