Java Program to Copy and Paste an image in OpenCV Last Updated : 15 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report OpenCV is a Machine Learning and open-source computer vision software library, the main purpose for which it was developed is to enable a common medium to increase the use of machine perception in commercial businesses and accelerate the development of computer vision applications, it is a smooth and easy transition for businesses to adopt and use OpenCV as it has the advantage of being BSD-licensed product. The library of OpenCV has 2000+ algorithms that are efficiently optimized and which also contains state-of-art computer vision and classical Machine Learning Algorithms.These Algorithms were mainly used for performing various tasks like recognizing faces, identification of objects, classification of human activities in videos, extraction of 3D models of objects, extraction of higher resolution in images, finding similar images from a picture database... etc.OpenCV also contains various language interfaces such as Java, Python, C++, MATLAB and it extensively supports Linux, Android, Windows, macOS. In other words, it supports almost all popular existing Operating Systems thus enabling a large Audience in its user's list.Input Image: Sample image present at the local directory in the system at the local directory. Here the directory from which the image is extracted to interpret as the multidimensional array is shown below: Local directory from where below sample image is copied: “C:/opencv/gfgarticleimg.png” Now, as we got to know what is OpenCV, let us try to build a java program that enables us in copying and pasting an image with OpenCV. Algorithm: Import OpenCV modules and load core libraries.Read the image from the local directory and store it in the Matrix object.Interpret image as a multi-dimensional matrix.Store this multi-dimensional structure writing to some different local directory as specified from where it is extracted to be. copied.Example: Java // Java Program to Copy and Paste an image in OpenCV // Importing all input output java classes import java.io.*; // Importing OpenCV modules import org.opencv.imgcodecs.Imgcodecs; import org.opencv.core.Mat; import org.opencv.core.Core; class GFG { // Main driver method public static void main(String[] args) { // Loading OpenCV core library System.loadLibrary(Core.Native_Library_Name); // Read image from file and // Store it in a Matrix object String f = "C:/opencv/gfgarticleimg.png"; // Creation of a Matrix object Mat m = Imgcodecs.imread(f); // Display message System.out.println( "Your Image has been Loaded......."); // Take another file for generating output image String f2 = "C:/opencv/gfgarticleimgResaved.png"; // Write the image Imgcodecs.imwrite(f2, m); // Display message System.out.println( "congrats! your image has been saved........"); } } Output : Local directory to where above sample shown below is pasted: “C:/opencv/gfgarticleimgResaved.png” Comment More infoAdvertise with us Next Article Java Program to Blur Images using OpenCV R ravi.geek24 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Practice Tags : Java Similar Reads Java Program to Add Text to an image in OpenCV OpenCV is the cross-platform open-source library for computer vision, image processing, and machine learning. Â It plays a major role nowadays in real-time operations in improving modules provides adequate functions for image manipulation. It has C++, C, Python, and Java interfaces and supports Windo 3 min read Java OpenCV Programs - Basic to Advanced Java is a popular programming language that can be used to create various types of applications, such as desktop, web, enterprise, and mobile. Java is also an object-oriented language, which means that it organizes data and behaviour into reusable units called classes and objects. Java is known for 2 min read Java Program to Extract a Image From a PDF Program to extract an image from a PDF using Java. The external jar file is required to import in the program. Below is the implementation for the same. Algorithm: Extracting image using the APACHE PDF Box module.Load the existing PDF document using file io.Creating an object of PDFRenderer class.Re 2 min read Java Program to Blur Images using OpenCV Blurring is a simple and frequently used image processing operation. It is also called as Smoothing. OpenCV library provides many functions to apply diverse linear filters to smooth images or blur images. Smoothing of an image removes noisy pixels from the image and applying a low-pass filter to an 4 min read Java Program to Convert PNG Images to JPEG PNG and JPG formats are used for image illustrations. Both the formats are used to provide good compatibilities with certain types of images like PNG works better with line drawings and icon graphics whereas JPG works well with photographs. However, both are interconvertible with respect to each oth 4 min read Java Program to Convert Byte Array to Image A byte array is the array of bytes that is used to store the collection of binary data. For example, the byte array of an image stores the information of every pixel of the image. In the byte array, we can store the content of any file in binary format. We can initialize the byte array with the byte 3 min read Like