2012-04-18 69 views
-1

我目前正在做一個關於使用離散小波變換的隱寫術的項目。我已經編寫了代碼並編譯了它。但是我面臨一些異常。一定幫我解釋異常。 唯一的例外是如下線程「AWT-EventQueue-0」中的異常

 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) 

我在堆棧新Overflow.Forgive我,如果我做了什麼錯誤,而張貼的問題。 謝謝

回覆: 對不起,先生我仍然熟悉論壇的規則。

的圖像中檢測皮膚區域的代碼是

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:3 在demo2.skindet(demo2.java:44) 在demo2.main(demo2.java:79)

感謝您replying.Regards

回答

2

這意味着你CAL ling Integer.parseInt來自Steganography.java的第292行(它異常地似乎持有名爲DWT的類而不是Steganography),但是您提供的是空值。

看起來這是爲了響應正在文本字段上執行的某些操作。

如果沒有看到您的代碼,我們無法確切地告訴您 - 您需要制定出爲什麼的值爲空。

編輯:好的,現在,它的改變到完全不同的錯誤,這就是問題所在:

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),你沒有重置counter,所以它是3 - 這是超出範圍。稍後您會遇到與scount相同的問題。

如果您在內部循環中使用之前聲明並初始化了countscount,那很好。

+0

謝謝你的回覆。我應該發佈我的代碼嗎?它的大約800行,所以我認爲這將是更好的發佈異常。 – user1320483 2012-04-19 03:35:53

+0

@ user1320483:理想情況下,您可以根據目前的信息自行執行診斷,如果卡住了,您可以發佈一個* short *但完整的程序來演示問題(並且僅限於問題)。這不需要800行。 – 2012-04-19 06:04:47

+0

先生我發佈了code.Please幫助@ Jon Skeet – user1320483 2012-04-20 12:02:33