Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. public static void zad6() {
  2. Mat image = Imgcodecs.imread("img.jpg", IMREAD_GRAYSCALE);
  3. Mat src = new Mat();
  4. Mat dst = new Mat();
  5. Mat dst1 = new Mat();
  6. Mat dst3 = new Mat();
  7. Mat kontury = new Mat();
  8. Mat kontury1 = new Mat();
  9. Mat kontury2 = new Mat();
  10. final Size kernelSize = new Size(11, 11);
  11. Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, kernelSize);
  12. final Point anchor = new Point(-1, -1);
  13. final int iterations = 2;
  14.  
  15. namedWindow("Ukasz", WINDOW_AUTOSIZE);
  16. imshow("Ukasz", image);
  17. waitKey(0);
  18.  
  19. int x = 25;
  20. int y = 5;
  21. System.out.println("x: " + x);
  22. System.out.println("y: " + y);
  23. adaptiveThreshold(image, src, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, x, y);
  24. imshow("Output", src);
  25. waitKey(0);
  26.  
  27. //pierwszy wzór
  28. Imgproc.dilate(src, dst, kernel, anchor);
  29. Core.subtract(dst, src, kontury);
  30.  
  31. //drugi wzór
  32. Imgproc.erode(src, dst1, kernel, anchor);
  33. Core.subtract(src, dst1, kontury1);
  34.  
  35. Core.subtract(dst, dst1, kontury2);
  36.  
  37. namedWindow("kontury1", WINDOW_AUTOSIZE);
  38. imshow("kontury1", kontury);
  39. waitKey(0);
  40.  
  41. namedWindow("kontury2", WINDOW_AUTOSIZE);
  42. imshow("kontury2", kontury1);
  43. waitKey(0);
  44.  
  45. namedWindow("kontury3", WINDOW_AUTOSIZE);
  46. imshow("kontury3", kontury2);
  47. waitKey(0);
  48. System.exit(0);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement