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.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.