 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to alter the sharpness of an image using Java OpenCV library?
Sharpening an image is the opposite of blur. To alter the sharpness of an image using the OpenCV library, you need to smooth/blur it using the Gaussian filter and subtract the smoothed version from the original image.
Example
import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.Size; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class AlteringSharpness {    public static void main (String[] args) {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );       //Reading the Image from the file       String file ="D:\Image\lamma1.jpg";       Mat src = Imgcodecs.imread(file, Imgcodecs.IMREAD_COLOR);       //Creating an empty matrix       Mat dest = new Mat(src.rows(), src.cols(), src.type());       Imgproc.GaussianBlur(src, dest, new Size(0,0), 10);       Core.addWeighted(src, 1.5, dest, -0.5, 0, dest);       // Writing the image       Imgcodecs.imwrite("D:\Image\altering_sharpness_100.jpg", dest);    } }  Input

Output

Advertisements
 