Link to home
Start Free TrialLog in
Avatar of MuhammadAdil
MuhammadAdilFlag for Pakistan

asked on

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;
    }
Avatar of Giant2
Giant2

Maybe the image you use cannot be filtered.
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MuhammadAdil

ASKER

Plz tell me code for Sharpen image with JAI.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial