Ejemplo n.º 1
0
  private static short[][] makeHSImap() {
    short[][] hue = new short[256][1];
    short[][] sat = new short[256][1];
    short[][] intens = new short[256][1];
    for (int i = 0; i < 256; i++) {
      hue[i][0] = (short) i;
      sat[i][0] = 255;
      intens[i][0] = (short) Math.round(255 * HSIImage.maxIntensity(i / 255.0, 1.0));
    }

    HSIImage hsiim = new HSIImage(hue, sat, intens);
    RGBImage rgbim = hsiim.makeRGBImage();
    short[][] red = rgbim.getRed();
    short[][] green = rgbim.getGreen();
    short[][] blue = rgbim.getBlue();

    short[][] colormap = new short[256][3];
    for (int i = 0; i < 256; i++) {
      colormap[i][0] = red[i][0];
      colormap[i][1] = green[i][0];
      colormap[i][2] = blue[i][0];
    }

    return colormap;
  }
Ejemplo n.º 2
0
  /**
   * A constructor that creates an IntensityImage from a RGBImage by letting the gray scale
   * intensity be the average of the red, green and blue intensities.
   *
   * @param rgbImage Original image.
   */
  public IntensityImage(RGBImage rgbImage) {
    this();

    int rows = rgbImage.getHeight();
    int cols = rgbImage.getWidth();

    data = new short[rows][cols];

    short[][] red = rgbImage.getRed();
    short[][] green = rgbImage.getGreen();
    short[][] blue = rgbImage.getBlue();

    int m;
    for (int row = 0; row < rows; row++) {
      for (int col = 0; col < cols; col++) {
        m = (red[row][col] + green[row][col] + blue[row][col]) / 3;
        data[row][col] = (short) m;
      }
    }
  }