In this article we will learn how to enhance contrast of an image using OpenCV library. In order to enhance contrast histogram equalization techniques are used.
For more information about histogram equalization techniques refer to this paper.
At first we need to setup OpenCV for Java, we recommend to use eclipse for the same since it is easy to use and setup. For installation refer to http://docs.opencv.org/2.4/doc/tutorials/introduction/java_eclipse/java_eclipse.html
Now lets understand some of the methods required for contrast enhancement.
- equalizeHist(source, destination) – This method resides in Imgproc package of OpenCv. source parameter is 8-bit single channel source image, and the destination parameter is the destination image
- Imcodecs.imread()/Imcodecs.imwrite() – These methods are used to read and write images as Mat objects which are rendered by OpenCV.
Note: The code will not work in online ide since it requires image in hard drive.
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Image Processing using OpenCV in Java | Set 13 (Brightness Enhancement)
- Image Processing using OpenCV in Java | Set 14 ( Sharpness Enhancement )
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 5 (Colored to Red Green Blue Image Conversion)
- Image Processing in Java | Set 7 (Creating a random pixel image)
- Image Processing in Java | Set 11 (Changing orientation of image)
- Image Processing in Java | Set 8 (Creating mirror image)
- Image Processing in Java | Set 10 ( Watermarking an image )
- Image Processing In Java | Set 2 (Get and set Pixels)
- Image Processing in Java | Set 1 (Read and Write)
- Image Processing in Java | Set 14 ( Comparison of two images )
- Image Processing in Java | Set 9 ( Face Detection )
- OpenCV | Hands on Image Contrast
- OpenCV | Understanding Contrast in an Image
- Image Edge Detection Operators in Digital Image Processing
- Getting started with Scikit-image: image processing in Python
- Image Processing without OpenCV | Python
- Redundancy in Digital Image Processing