This is the code from filthy rich clients--by Chet Hasse.
private void buildConvolveOpTab(JTabbedPane tabbedPane) {
BufferedImage dstImage = null;
float[] sharpen = new float[] {
0.0f, -1.0f, 0.0f,
-1.0f, 5.0f, -1.0f,
0.0f, -1.0f, 0.0f
};
Kernel kernel = new Kernel(3, 3, sharpen);
ConvolveOp op = new ConvolveOp(kernel);
dstImage = op.filter(sourceImage, null);
tabbedPane.add("Convolve", new JLabel(new ImageIcon(dstImage)));
}
Can anyone please tell me how to decide the elements of that matrix "sharpen". I have googled it a lot but didn't find anything useful. Thanx in advance.
This is just one of the discrete convolution kernel, mostly used in image processing to apply various spatial filters like blur or sharpen or edge detection. The particular kernel that you have mentioned is approximation of laplacian sharpen filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With