公司做一个图像识别的项目,要我用java做BMP图片的底层识别处理,我做了基本上一个月但是程序始终不稳定,最后没办法让别人转用C语言来做,我真的很不明白,java适合做图像处理么,现在这些处理图片得到的数据乱七八糟的,我头都疼了,我想问一下java到底适合做图像处理吗?和MATLAB,VC和C比呢??

解决方案 »

  1.   

    去看一下java数值计算吧,可能会有收获
      

  2.   

    谢谢各位的回答,但是我现在很郁闷,为什么这个函数里面的PixelGrabber类的pixGrb对象得到的图像数据全部是负数呢而且相当大,我现在只知道这一种获得图像数据的方法了 
    private int[] getPixArray(Image img, int width, int height) { int[] pixArray = new int[width * height]; try { 
    //创建一个 PixelGrabber 对象以便从指定图像中抓取像素的 (x, y, w, h) 矩形部分放入给定数组中。 
    PixelGrabber pixGrb = new PixelGrabber(img, 0, 0, width, height, pixArray, 0, width); 
    if (pixGrb.grabPixels() != true) 
    try { 
    throw new java.awt.AWTException(Constants.ERR_GET_IMAGE + pixGrb.status()); 
    } catch (Exception eq) { 
    eq.printStackTrace(); 

    } catch (Exception ex) { 
    ex.printStackTrace(); } 
    return pixArray; 
    }
      

  3.   

    ......
    负数是因为.....
    试一下这个看符合你要求不,RGB空间
    ColorModel colorModel=ColorModel.getRGBdefault();
    double r = (double)colorModel.getRed(pixel[k]);
         double g = (double)colorModel.getGreen(pixel[k]);
         double b = (double)colorModel.getBlue(pixel[k]);
      

  4.   

    对 grabPixels以后有没有对RGB ColorModel的pixel数据进行对应处理呢public void handlesinglepixel(int x, int y, int pixel) {
            int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = (pixel      ) & 0xff;
            // Deal with the pixel as necessary...
    }
      

  5.   


    public void handlesinglepixel(int x, int y, int pixel) {
            int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = (pixel      ) & 0xff;
            // Deal with the pixel as necessary...
    }这段是什么意思?不太明白,应用在什么地方,参数是什么意思?能给解释一下嘛受累 谢谢
      

  6.   

    pixel是获取的pixelArray的元素
    这段只是将32位的pixel数据分解 
    四个颜色有效分段都是按位由高到低排列的
    接下来就可以用此四个数据自由处理
      

  7.   


    private int[] getPixArray(Image img, int width, int height) { int[] pixArray = new int[width * height]; try {
    //创建一个 PixelGrabber 对象以便从指定图像中抓取像素的 (x, y, w, h) 矩形部分放入给定数组中。
    PixelGrabber pixGrb = new PixelGrabber(img, 0, 0, width, height, pixArray, 0, width);
    if (pixGrb.grabPixels() != true){
    try {
    throw new java.awt.AWTException(Constants.ERR_GET_IMAGE + pixGrb.status());
    } catch (Exception eq) {
    eq.printStackTrace();
    }
    }else{
    for(int i = 0; i < pixArray.length; i++){
    int alpha = (pixArray[i] >> 24) & 0xff;
            int red   = (pixArray[i] >> 16) & 0xff;
            int green = (pixArray[i] >>  8) & 0xff;
            int blue  = (pixArray[i]      ) & 0xff;
    }
    }
    } catch (Exception ex) {
    ex.printStackTrace(); }
    return pixArray;
    }这样写可以么?
      

  8.   

    一般都是C/Python做这种东西了,就是C#也比Java强啊。