Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package przetwarzanieobrazu;
  7.  
  8. import org.opencv.core.Core;
  9. import org.opencv.core.CvType;
  10. import static org.opencv.core.CvType.CV_8UC4;
  11. import org.opencv.core.Mat;
  12. import static org.opencv.highgui.HighGui.WINDOW_AUTOSIZE;
  13. import static org.opencv.highgui.HighGui.imshow;
  14. import static org.opencv.highgui.HighGui.namedWindow;
  15. import static org.opencv.highgui.HighGui.waitKey;
  16. import org.opencv.imgcodecs.Imgcodecs;
  17. import static org.opencv.imgcodecs.Imgcodecs.IMREAD_GRAYSCALE;
  18. import static org.opencv.imgcodecs.Imgcodecs.IMREAD_UNCHANGED;
  19. import static org.opencv.imgcodecs.Imgcodecs.imread;
  20.  
  21. /**
  22. *
  23. * @author Lukasz Laskowski
  24. */
  25. public class PrzetwarzanieObrazu {
  26. static {
  27. System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  28. }
  29. /**
  30. * @param args the command line arguments
  31. */
  32.  
  33.  
  34. public static void zad1(){
  35. Mat img = new Mat(3, 3, CvType.CV_8U);
  36. int row = 0, col = 0;
  37. img.put(row, col, 1, 2, 3, 3, 5, 6, 6, 7, 8);
  38. System.out.println(img.dump());
  39. }
  40. public static void zad2(){
  41. Mat image = Imgcodecs.imread("D:\\LV\\Tapety\\1.jpg", IMREAD_UNCHANGED);
  42. System.out.println("img loaded!");
  43.  
  44. Imgcodecs.imwrite("1.jpg", image);
  45. System.out.print("img saved!");
  46. }
  47. public static void zad3(){
  48.  
  49.  
  50. Mat image = Imgcodecs.imread("1.jpg", IMREAD_UNCHANGED);
  51. System.out.println("img loaded!");
  52.  
  53. namedWindow("Earth", WINDOW_AUTOSIZE );
  54. imshow("Earth", image);
  55. waitKey(0);
  56. }
  57. public static void zad4(){
  58.  
  59.  
  60. Mat image = Imgcodecs.imread("1.jpg", IMREAD_GRAYSCALE);
  61. System.out.println("img loaded!");
  62.  
  63. namedWindow("Earth", WINDOW_AUTOSIZE );
  64. imshow("Earth", image);
  65. waitKey(0);
  66. }
  67. public static void zad5(){
  68.  
  69.  
  70. Mat image1 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\1.jpg", IMREAD_UNCHANGED);
  71. namedWindow("Earth", WINDOW_AUTOSIZE );
  72. imshow("Earth", image1);
  73. waitKey(0);
  74.  
  75. Mat image2 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\2.png", IMREAD_UNCHANGED);
  76. namedWindow("Earth", WINDOW_AUTOSIZE );
  77. imshow("Earth", image2);
  78. waitKey(0);
  79.  
  80. Mat image3 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\3.bmp", IMREAD_UNCHANGED);
  81. namedWindow("Earth", WINDOW_AUTOSIZE );
  82. imshow("Earth", image3);
  83. waitKey(0);
  84.  
  85. // Mat image4 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\4.gif", IMREAD_UNCHANGED);
  86. // namedWindow("Earth", WINDOW_AUTOSIZE );
  87. // imshow("Earth", image4);
  88.  
  89. waitKey(0);
  90. }
  91. public static void zad6(){
  92.  
  93. }
  94. public static void main(String[] args) {
  95.  
  96.  
  97. zad1();
  98. zad2();
  99. zad3();
  100. zad4();
  101. zad5();
  102.  
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement