异常的线程“AWT-EventQueue-0”

时间:2022-01-26 17:36:06

I am currently doing a project on steganography using discrete Wavelet Transform.I have already written the code and compiled it.However I am facing some exceptions.Kindly help me interpret the exceptions. The exception is as follows

我目前正在做一个关于隐写术的项目,使用离散小波变换。我已经编写并编译了代码。然而,我面临着一些例外。请帮我解释一下这些例外情况。例外情况如下

        Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at DWT.dwtFunc(Steganography.java:292)
        at TextInput.actionPerformed(Steganography.java:252)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

I am new in Stack Overflow.Forgive me if I have made any mistake while posting the question. Thank You

我是栈溢出的新手。如果我在发布问题时犯了任何错误,请原谅。谢谢你!

Re: Sorry Sir I am still getting acquainted to the rules of the forum.

对不起,先生,我还在熟悉论坛的规则。

The code for detection of skin region in an image is

图像中皮肤区域的检测代码是

    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import java.io.*;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    import javax.swing.filechooser.FileNameExtensionFilter;
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.lang.*;

    public class demo2
    {

        public void skindet()
        {
            float[] hsvval;
            float hue,sat,val;
            int counter = 0;
            String[] skinpixel = new String[200000];
            int scount = 0;
            try
            {

                BufferedImage image = ImageIO.read(new File("lena.png"));
                int[][] rgb=new int[550][550];
                int w = image.getWidth();
                int h = image.getHeight();
                hsvval=new float[3];
                int red,green,blue;
                for (int i=0;i<w;i++) 
                {
                    for (int j=0;j<h;j++)
                    {
                        rgb[i][j] =image.getRGB(i,j);
                        red=(rgb[i][j] >> 16) & 0xff;
                        green=(rgb[i][j] >> 8) & 0xff;
                        blue=(rgb[i][j]) & 0xff;
                        float[] values = Color.RGBtoHSB(red,green,blue,null);
                        for(int s=0;s<3;s++)
                        {
                            hsvval[counter]=values[s];
                            counter++;
                        }
                        hue=hsvval[0];
                        sat=hsvval[1];
                        val=hsvval[2];
                        if(hue>0 && hue<0.11 && sat>0.2 && sat<0.7)
                        {
                            String xcor=Integer.toString(i);
                            String ycor=Integer.toString(j);
                            skinpixel[scount]=xcor;
                            scount++;
                            skinpixel[scount]=ycor;
                            scount++;
                        }
                    }
                }
                int length=skinpixel.length;
                for(int i=0;i<length;i++)
                    System.out.println(skinpixel[i]+"\n");

            }

            catch(Exception e)
            {
                e.printStackTrace();
            }


        }

        public static void main(String args[])
        {

            demo2 dem=new demo2();
            dem.skindet();
        }

    }

The exception is

唯一的例外是

java.lang.ArrayIndexOutOfBoundsException: 3 at demo2.skindet(demo2.java:44) at demo2.main(demo2.java:79)

. lang。ArrayIndexOutOfBoundsException: 3 at demo2.skindet(demo2.java:44) at demo2.main(demo2.java:79)

Thank You for replying.Regards

谢谢你replying.Regards

1 个解决方案

#1


2  

It means that you're calling Integer.parseInt from line 292 of Steganography.java (which unusually appears to hold a class called DWT rather than Steganography), but you're providing a null value.

它表示你调用的是整数。从第292行开始。java(不同寻常的是,它包含一个名为DWT的类,而不是隐写),但是您提供了一个空值。

It looks like this is in response to some action being performed on a text field.

看起来这是对在文本字段上执行的一些操作的响应。

We can't really tell a lot more without seeing your code - you need to work out why the value is null.

在没有看到代码的情况下,我们不能透露更多信息——您需要找出为什么值为null。

EDIT: Okay, now that it's changed to a completely different error, this is the problem:

编辑:好的,现在它变成了一个完全不同的错误,这就是问题所在:

int counter = 0;

hsvval=new float[3];
...
for (int i=0;i<w;i++) 
{
    for (int j=0;j<h;j++)
    {
        ...
        for(int s=0;s<3;s++)
        {
            hsvval[counter]=values[s];
            counter++;
        }
        ...          
    }
}

So the first time the inner loop is executed, it's fine - but on the second iteration of the middle loop (j = 1), you haven't reset counter, so it's 3 - which is out of range. You've got the same problem with scount later.

因此,第一次执行内部循环时,它是可以的——但是在中间循环的第二次迭代(j = 1)中,您没有重置计数器,所以它是3 -,这超出了范围。你以后也会遇到同样的问题。

If you declare and initialize count and scount just before they're used in the inner loop, it's fine.

如果在内部循环中使用count和scount之前声明并初始化计数和scount,那就可以了。

#1


2  

It means that you're calling Integer.parseInt from line 292 of Steganography.java (which unusually appears to hold a class called DWT rather than Steganography), but you're providing a null value.

它表示你调用的是整数。从第292行开始。java(不同寻常的是,它包含一个名为DWT的类,而不是隐写),但是您提供了一个空值。

It looks like this is in response to some action being performed on a text field.

看起来这是对在文本字段上执行的一些操作的响应。

We can't really tell a lot more without seeing your code - you need to work out why the value is null.

在没有看到代码的情况下,我们不能透露更多信息——您需要找出为什么值为null。

EDIT: Okay, now that it's changed to a completely different error, this is the problem:

编辑:好的,现在它变成了一个完全不同的错误,这就是问题所在:

int counter = 0;

hsvval=new float[3];
...
for (int i=0;i<w;i++) 
{
    for (int j=0;j<h;j++)
    {
        ...
        for(int s=0;s<3;s++)
        {
            hsvval[counter]=values[s];
            counter++;
        }
        ...          
    }
}

So the first time the inner loop is executed, it's fine - but on the second iteration of the middle loop (j = 1), you haven't reset counter, so it's 3 - which is out of range. You've got the same problem with scount later.

因此,第一次执行内部循环时,它是可以的——但是在中间循环的第二次迭代(j = 1)中,您没有重置计数器,所以它是3 -,这超出了范围。你以后也会遇到同样的问题。

If you declare and initialize count and scount just before they're used in the inner loop, it's fine.

如果在内部循环中使用count和scount之前声明并初始化计数和scount,那就可以了。