示例#1
0
  public static BufferedImage grayUnsigned(ImageInteger src, BufferedImage dst, int normalize) {
    dst = checkInputs(src, dst);

    if (src.getDataType().isSigned())
      throw new IllegalArgumentException("Can only convert unsigned images.");

    for (int y = 0; y < src.height; y++) {
      for (int x = 0; x < src.width; x++) {
        int v = src.get(x, y);

        int rgb = 255 * v / normalize;

        dst.setRGB(x, y, rgb << 16 | rgb << 8 | rgb);
      }
    }

    return dst;
  }