-1

私は現在、離散ウェーブレット変換を使用したステガノグラフィーに関するプロジェクトを行っています。すでにコードを作成してコンパイルしています。ただし、いくつかの例外に直面しています。例外の解釈を手伝ってください。例外は次のとおりです

        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)

私は Stack Overflow の初心者です。質問の投稿中に間違いを犯した場合はご容赦ください。ありがとうございました

Re: 申し訳ありませんが、私はまだフォーラムのルールに精通しています。

画像内の皮膚領域を検出するためのコードは次のとおりです。

    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();
        }

    }

例外は

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

返信ありがとうございます。

4

1 に答える 1

2

これは、(ではなくと呼ばれるクラスを保持しているように見える)Integer.parseIntの292行目から呼び出しているが、null値を指定していることを意味します。Steganography.javaDWTSteganography

これは、テキストフィールドで実行されているアクションに応答しているようです。

コードを見ずにこれ以上多くのことを知ることはできません。値がnullである理由を理解する必要があります。

編集:さて、それが完全に異なるエラーに変更されたので、これが問題です:

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++;
        }
        ...          
    }
}

したがって、最初に内側のループが実行されるときは問題ありませんが、中央のループ(j = 1)の2回目の反復ではリセットされていないcounterため、3になります。これは範囲外です。後で同じ問題が発生しscountます。

宣言して初期化し、それらが内部ループで使用される直前であれば、count問題ありませscount ん。

于 2012-04-18T14:42:53.813 に答える