code: public ImageWritable asWritable(File f) throws IOException {
          try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f))) {
              Mat mat = streamToMat(bis);
              Mat image = imdecode(mat, IMREAD_ANYDEPTH | IMREAD_ANYCOLOR);
              if (image == null || image.empty()) {
                  PIX pix = pixReadMem(mat.data(), mat.cols());
                  if (pix == null) {
                      throw new IOException("Could not decode image from input stream");
                  }
                  image = convert(pix);
                  pixDestroy(pix);
              }
  
              ImageWritable writable = new ImageWritable(converter.convert(image));
              return writable;
          }
      }
docs: Convert a file to a INDArray
  
  @param f the image to convert
  @return INDArray
  @throws IOException