Example #1
0
  public static BufferedImage standard(ImageSingleBand<?> src, BufferedImage dst) {
    if (src.getDataType().isInteger()) {
      ImageInteger srcInt = (ImageInteger) src;

      if (src.getDataType().isSigned()) {
        double max = GImageStatistics.maxAbs(srcInt);
        return colorizeSign(srcInt, dst, (int) max);
      } else {
        if (src.getDataType().getNumBits() == 8) {
          dst = ConvertBufferedImage.convertTo((ImageUInt8) src, dst);
        } else {
          double max = GImageStatistics.maxAbs(srcInt);
          dst = grayUnsigned(srcInt, dst, (int) max);
        }
      }
    } else if (ImageFloat32.class.isAssignableFrom(src.getClass())) {
      ImageFloat32 img = (ImageFloat32) src;
      float max = ImageStatistics.maxAbs(img);

      boolean hasNegative = false;
      for (int i = 0; i < img.getHeight(); i++) {
        for (int j = 0; j < img.getWidth(); j++) {
          if (img.get(j, i) < 0) {
            hasNegative = true;
            break;
          }
        }
      }

      if (hasNegative) return colorizeSign(img, dst, (int) max);
      else return grayMagnitude((ImageFloat32) src, dst, max);
    }

    return dst;
  }
Example #2
0
  /**
   * Renders a gray scale image using color values from cold to hot.
   *
   * @param src Input single band image.
   * @param dst Where the image is rendered into. If null a new BufferedImage will be created and
   *     return.
   * @param normalize Used to normalize the input image.
   * @return Rendered image.
   */
  public static BufferedImage grayMagnitudeTemp(
      ImageSingleBand src, BufferedImage dst, double normalize) {
    if (normalize < 0) normalize = GImageStatistics.maxAbs(src);

    dst = checkInputs(src, dst);

    if (src.getDataType().isInteger()) {
      return grayMagnitudeTemp((ImageInteger) src, dst, (int) normalize);
    } else {
      throw new RuntimeException("Add support");
    }
  }
Example #3
0
  /**
   * Renders a gray scale image of the input image's intensity.<br>
   * <br>
   * dst(i,j) = 255*abs(src(i,j))/normalize
   *
   * @param src Input single band image.
   * @param dst Where the image is rendered into. If null a new BufferedImage will be created and
   *     return.
   * @param normalize Used to normalize the input image. If < 0 then this value is automatically
   *     computed.
   * @return Rendered image.
   */
  public static BufferedImage grayMagnitude(
      ImageSingleBand src, BufferedImage dst, double normalize) {
    if (normalize < 0) normalize = GImageStatistics.maxAbs(src);

    dst = checkInputs(src, dst);

    if (src.getDataType().isInteger()) {
      return grayMagnitude((ImageInteger) src, dst, (int) normalize);
    } else {
      return grayMagnitude((ImageFloat32) src, dst, (float) normalize);
    }
  }
Example #4
0
  /**
   * Renders a gray scale image using color values from cold to hot.
   *
   * @param disparity Input disparity image
   * @param dst Where the image is rendered into. If null a new BufferedImage will be created and
   *     return.
   * @param minDisparity Minimum disparity that can be computed
   * @param maxDisparity Maximum disparity that can be computed
   * @param invalidColor RGB value for invalid pixels. Try 0xFF << 8 for green
   * @return Rendered image.
   */
  public static BufferedImage disparity(
      ImageSingleBand disparity,
      BufferedImage dst,
      int minDisparity,
      int maxDisparity,
      int invalidColor) {
    if (dst == null)
      dst =
          new BufferedImage(
              disparity.getWidth(), disparity.getHeight(), BufferedImage.TYPE_INT_RGB);

    if (disparity.getDataType().isInteger()) {
      return disparity((ImageInteger) disparity, dst, minDisparity, maxDisparity, invalidColor);
    } else if (disparity instanceof ImageFloat32) {
      return disparity((ImageFloat32) disparity, dst, minDisparity, maxDisparity, invalidColor);
    } else {
      throw new RuntimeException("Add support");
    }
  }