public INDArray asMatrix(BufferedImage image){
  if (channels == 3) {
    return toBgr(image);
  }
 else {
    image=scalingIfNeed(image,true);
    int w=image.getWidth();
    int h=image.getHeight();
    INDArray ret=Nd4j.create(h,w);
    for (int i=0; i < h; i++) {
      for (int j=0; j < w; j++) {
        ret.putScalar(new int[]{i,j},image.getRGB(i,j));
      }
    }
    return ret;
  }
}

public INDArray asMatrix ( BufferedImage image ) { if ( channels == 3 ) { return toBgr ( image ) ; } else { image = scalingIfNeed ( image , true ) ; int w = image . getWidth ( ) ; int h = image . getHeight ( ) ; INDArray ret = Nd4j . create ( h , w ) ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { ret . putScalar ( new int [ ] { i , j } , image . getRGB ( i , j ) ) ; } } return ret ; } }
convert an bufferedimage to a matrix
