Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package przetwarzanieobrazu;
- import org.opencv.core.Core;
- import org.opencv.core.CvType;
- import static org.opencv.core.CvType.CV_8UC4;
- import org.opencv.core.Mat;
- import static org.opencv.highgui.HighGui.WINDOW_AUTOSIZE;
- import static org.opencv.highgui.HighGui.imshow;
- import static org.opencv.highgui.HighGui.namedWindow;
- import static org.opencv.highgui.HighGui.waitKey;
- import org.opencv.imgcodecs.Imgcodecs;
- import static org.opencv.imgcodecs.Imgcodecs.IMREAD_GRAYSCALE;
- import static org.opencv.imgcodecs.Imgcodecs.IMREAD_UNCHANGED;
- import static org.opencv.imgcodecs.Imgcodecs.imread;
- /**
- *
- * @author Lukasz Laskowski
- */
- public class PrzetwarzanieObrazu {
- static {
- System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
- }
- /**
- * @param args the command line arguments
- */
- public static void zad1(){
- Mat img = new Mat(3, 3, CvType.CV_8U);
- int row = 0, col = 0;
- img.put(row, col, 1, 2, 3, 3, 5, 6, 6, 7, 8);
- System.out.println(img.dump());
- }
- public static void zad2(){
- Mat image = Imgcodecs.imread("D:\\LV\\Tapety\\1.jpg", IMREAD_UNCHANGED);
- System.out.println("img loaded!");
- Imgcodecs.imwrite("1.jpg", image);
- System.out.print("img saved!");
- }
- public static void zad3(){
- Mat image = Imgcodecs.imread("1.jpg", IMREAD_UNCHANGED);
- System.out.println("img loaded!");
- namedWindow("Earth", WINDOW_AUTOSIZE );
- imshow("Earth", image);
- waitKey(0);
- }
- public static void zad4(){
- Mat image = Imgcodecs.imread("1.jpg", IMREAD_GRAYSCALE);
- System.out.println("img loaded!");
- namedWindow("Earth", WINDOW_AUTOSIZE );
- imshow("Earth", image);
- waitKey(0);
- }
- public static void zad5(){
- Mat image1 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\1.jpg", IMREAD_UNCHANGED);
- namedWindow("Earth", WINDOW_AUTOSIZE );
- imshow("Earth", image1);
- waitKey(0);
- Mat image2 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\2.png", IMREAD_UNCHANGED);
- namedWindow("Earth", WINDOW_AUTOSIZE );
- imshow("Earth", image2);
- waitKey(0);
- Mat image3 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\3.bmp", IMREAD_UNCHANGED);
- namedWindow("Earth", WINDOW_AUTOSIZE );
- imshow("Earth", image3);
- waitKey(0);
- // Mat image4 = Imgcodecs.imread("D:\\LV\\Tapety\\work\\4.gif", IMREAD_UNCHANGED);
- // namedWindow("Earth", WINDOW_AUTOSIZE );
- // imshow("Earth", image4);
- waitKey(0);
- }
- public static void zad6(){
- }
- public static void main(String[] args) {
- zad1();
- zad2();
- zad3();
- zad4();
- zad5();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement