Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help to understand matrix used in Kernel Class for ConvolveOp

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.

like image 585
Naveen Avatar asked Nov 17 '25 14:11

Naveen


1 Answers

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.

  1. Reference: http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
  2. Convolution Filter Applet: http://homepages.inf.ed.ac.uk/rbf/HIPR2/convolutiondemo.htm
like image 193
Shivam Avatar answered Nov 19 '25 05:11

Shivam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!