Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:34:50+00:00 2026-06-05T22:34:50+00:00

I am trying to apply smoothing filter to image . But I get this

  • 0

I am trying to apply smoothing filter to image . But I get this bug :

java.awt.image.ImagingOpException: Unable to convolve src image
at java.awt.image.ConvolveOp.filter(ConvolveOp.java:180)
at ocr.Resolution.smoothing(Resolution.java:102)
at ocr.Interface$ButtonListener.actionPerformed(Interface.java:332)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)

I have researched but couldn’t find any exact solution. To see the source of problem , I have load images as icon . They are ok. Can the reason of this problem be that the image is loading later , so it couldn’t apply the filter ?

Also , I will apply thinning algorithm and some other filters too. Do you think If it is better to do in Processing instead of Java. Thank you for any help.

        filter = new float[] { 1.0f/121.0f,  2.0f/121.0f,   3.0f/121.0f,   2.0f/121.0f,   1.0f/121.0f,
                            2.0f/121.0f,  7.0f/121.0f,  11.0f/121.0f,   7.0f/121.0f,   2.0f/121.0f,
                            3.0f/121.0f, 11.0f/121.0f,  17.0f/121.0f,  11.0f/121.0f,   3.0f/121.0f,
                            2.0f/121.0f,  7.0f/121.0f,  11.0f/121.0f,   7.0f/121.0f,   2.0f/121.0f,
                            1.0f/121.0f,  2.0f/121.0f,   3.0f/121.0f,   2.0f/121.0f,   1.0f/121.0f};
    kernelWidth = 5;
    kernelHeight = 5;
    BufferedImageOp bufOp ;
    BufferedImage bufImg;
    Image img;

    img = Toolkit.getDefaultToolkit().getImage(Interface.picPath); //load image        
    ImageSize size = new ImageSize(img);// instance to get image dimensions
    bufImg = new BufferedImage (size.getwidth(),size.getheight(),BufferedImage.TYPE_INT_RGB); 
    try {
    bufImg = ImageIO.read(new File(Interface.picPath) );

    } catch (IOException ex) {
    Logger.getLogger(Resolution.class.getName()).log(Level.SEVERE, null, ex);
    }

    kernel = new Kernel( kernelWidth, kernelHeight, filter);
    bufOp = new ConvolveOp(kernel); 
    bufImg = bufOp.filter(bufImg, null);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:34:54+00:00Added an answer on June 5, 2026 at 10:34 pm

    I have found a solution. Instead of creating BufferedImage(bufImg) using URl, I converted the image itself (img ) to BufferedImage and it runs now.

    public void smoothing(){
         filter = new float[] { 1.0f/121.0f,  2.0f/121.0f,   3.0f/121.0f,   2.0f/121.0f,   1.0f/121.0f,
                                2.0f/121.0f,  7.0f/121.0f,  11.0f/121.0f,   7.0f/121.0f,   2.0f/121.0f,
                                3.0f/121.0f, 11.0f/121.0f,  17.0f/121.0f,  11.0f/121.0f,   3.0f/121.0f,
                                2.0f/121.0f,  7.0f/121.0f,  11.0f/121.0f,   7.0f/121.0f,   2.0f/121.0f,
                                1.0f/121.0f,  2.0f/121.0f,   3.0f/121.0f,   2.0f/121.0f,   1.0f/121.0f};
        kernelWidth = 5;
        kernelHeight = 5;
        kernel = new Kernel( kernelWidth, kernelHeight, filter);
        op = new ConvolveOp(kernel); 
    
        img = Toolkit.getDefaultToolkit().getImage(Interface.picPath);
        imageToBufferedImage(img);
        bufImg = op.filter(bufImg, null);
    
        icon = new ImageIcon(img.getScaledInstance(175, 175, Image.SCALE_DEFAULT));
        icon2 = new ImageIcon(img.getScaledInstance(300, 300, Image.SCALE_DEFAULT));
        Interface.label3.setIcon(icon);
        Interface.label8.setIcon(icon2);
    
    }
    
    public  void imageToBufferedImage(Image im) {
        ImageSize size = new ImageSize(im);
        bufImg = new BufferedImage (size.getwidth(), size.getheight(),BufferedImage.TYPE_INT_RGB);
        Graphics graph = bufImg.getGraphics();
        graph.drawImage(im, 0, 0, null);
        graph.dispose();
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to apply a transformation to an mpl::string , but can't get it
im trying to apply this JSON code to my Google Map: [ { stylers:
I'm trying to apply a tooltip to a foreach loop, but I need the
I'm trying to apply a custom RGB color to background, but it is not
I'm trying to apply a first-child class on to a button, using this markup:
I'm trying to apply CSS to my <h:inputText> but without success so far :
Using the proprietary filter css in IE (7/8). Trying to apply an additional filter
I'm not the best at this jquery stuff. But I'm trying to seperate the
i'm trying to have the following structure get /something/id/apply => controller 1 post /something/id/apply
GOAL: I'm trying to apply a Like button to my blog - this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.