
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
How to perform Bitwise Not operation on images using Java OpenCV?
You can compute the bitwise conjunction between two images using the bitwise_not() method of the org.opencv.core.Core class.
This method accepts two Mat objects representing the source and destination matrices, calculates the inverse of each element in the source matrix and stores the result in the destination matrix.
Example
import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; public class BitwiseNOTExample { public static void main(String args[]) throws Exception { //Loading the OpenCV core library System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); //Reading the Image String file ="D://images//elephant.jpg"; Mat src = Imgcodecs.imread(file); HighGui.imshow("Grayscale Image", src); //Creating an empty matrix to store the result Mat dst = new Mat(src.rows(), src.cols(), src.type()); //Applying bitwise not operation Core.bitwise_not(src, dst); HighGui.imshow("Bitwise NOT operation", dst); HighGui.waitKey(); } }
Input Image
Output
On executing, the above program generates the following windows −
- Related Articles
- How to perform Bitwise OR operation on two images using Java OpenCV?
- How to perform Bitwise XOR operation on two images using Java OpenCV?
- How to perform Bitwise And operation on two images using Java OpenCV?
- How to perform bitwise XOR operation on images in OpenCV Python?
- How to perform bitwise AND operation on two images in OpenCV Python?
- How to perform bitwise OR operation on two images in OpenCV Python?
- OpenCV Python – How to perform bitwise NOT operation on an image?
- Performing white TopHat operation on images using OpenCV
- Performing white BlackHat operation on images using OpenCV
- How to perform bilateral filter operation on an image in OpenCV using Python?
- C++ Program to Perform Addition Operation Using Bitwise Operators
- OpenCV Python – How to perform SQRBox filter operation on an image?
- How to blend to images using OpenCV Java?
- How to compare two images using Java OpenCV library?
- Java Program to perform XOR operation on BigInteger

Advertisements