Image Processing in Java – Sharpness Enhancement
- Image Processing in Java – Read and Write
- Image Processing In Java – Get and Set Pixels
- Image Processing in Java – Colored Image to Grayscale Image Conversion
- Image Processing in Java – Colored Image to Negative Image Conversion
- Image Processing in Java – Colored to Red Green Blue Image Conversion
- Image Processing in Java – Colored Image to Sepia Image Conversion
- Image Processing in Java – Creating a Random Pixel Image
- Image Processing in Java – Creating a Mirror Image
- Image Processing in Java – Face Detection
- Image Processing in Java – Watermarking an Image
- Image Processing in Java – Changing Orientation of Image
- Image Processing in Java – Contrast Enhancement
- Image Processing in Java – Brightness Enhancement
- Image Processing in Java – Comparison of Two Images
Tip: It is recommended to use eclipse for the same since it is easy to use and set up.
Here, we will use a Gaussian filter. This filter reduces the noise in the image and makes it look better (or higher resolution). Go through the pre-requisite of installing OpenCV and setup as per OS in your local machine in order to write code as we will be importing libraries. So let us discuss prior methods required for sharpness enhancement.
Method 1: GaussianBlur(): This method resides in Imgproc package of OpenCv.
Imgproc.GaussianBlur(source, destination, new Size(0, 0), sigmaX)
- Source image
- Destination image
- Gaussian kernel size
- Gaussian kernel standard deviation in X direction
Method 2: addWeighted(): This method resides in the Core package of OpenCV.
Core.addWeighted(InputArray src1, alpha, src2, beta, gamma, OutputArray dst)
- First input array
- Weight of the first array elements
- Second input array of the same size and channel number as src1
- Weight of the second array elements
- Scalar added to each sum
- Output array that has the same size and number of channels as the input arrays
Method 3: imread(): It is used to read images as Mat objects which are rendered by OpenCV.
Parameters: Filename of the image file. If the image is in another directory whole path of the image must be mentioned.
Method 4: imwrite(): It is used to write Mat objects to an image file.
- Filename of the image file. If the image is in another directory whole path of an image must be mentioned.
- Resultant mat object.
Implementation: The input image is as follows:
Note: Do notice a minor improvement in resolution
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.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.
Please Login to comment...