[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1232
  • Last Modified:

Sharpen Image with Java

I use this Method to sharpen an Image. But i m gotting error. ("unable to convolve src Image")
public BufferedImage changeSharpness(BufferedImage img, int sharpen)
    {
        try{
        for(int i=0;i<sharpen;i++){
       
        Kernel kernel = new Kernel(3, 3,
        new float[] {
            -1, -1, -1,
            -1, 9, -1,
            -1, -1, -1});

        BufferedImageOp op= new ConvolveOp(kernel);
        buff = op.filter(img,null);
        }
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(new JFrame(),e.getMessage(),"Test",0);
        }
        return buff;
    }
0
MuhammadAdil
Asked:
MuhammadAdil
3 Solutions
 
Giant2Commented:
Maybe the image you use cannot be filtered.
0
 
hoomanvCommented:
0
 
fffej78Commented:
The following bug report seems apt for you:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4957775

As a workaround, the recommended solution is to "Convert it to a simpler image by either creating a new BufferedImage with the same dimensions and TYPE_RGB, then getting the graphics and drawing it before convolving"

Hope that helps.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Giant2Commented:
I see in the doc: the exception is throwed up when the image used cannot be filtered.
0
 
MuhammadAdilAuthor Commented:
Plz tell me code for Sharpen image with JAI.
0
 
fffej78Commented:
Goto https://jai.dev.java.net/ and download the demos there and adapt them to suit you or read the documentation at http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Image-enhance.doc.html#51172

You could just try to work around suggested in the bug report!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now