Esempio n. 1
0
  /*
   * Traverses the original and mask images in tandem.
   * The mask should be identical to the original except it
   * should have been preselected to be a binary image.
   *
   * Wherever the mask has a 1 value, add that pixel value to
   * the list.
   *
   * Return the list unsorted and only containing pixel values of
   * the original matching a corresponding mask 1-value.
   *
   * @param orig
   * 		The original ImageData image
   * @param mask
   * 		The corresponding ImageData mask (having identical dimensions and containing binary values)
   *
   */
  public ArrayList mask(ImageData orig, ImageData mask) {
    ArrayList list =
        new ArrayList(); // a column-wise traversal of the input images populates this 1D list

    for (int col = 0; col < orig.getNumCols(); col++) {
      for (int row = 0; row < orig.getNumRows(); row++) {
        for (int band = 0; band < orig.getNumBands(); band++) {
          if (mask.getValue(row, col, band) == 1) {
            list.add(new Double(orig.getValue(row, col, band)));
          }
        }
      }
    }
    return list;
  }
Esempio n. 2
0
  /*
   * Returns the sum of the pixel values of a given ImageData.
   * @param o
   * 		The ImageData providing pixels to be counted
   */
  public double sum(ImageData o) {
    double sum = 0;

    for (int row = 0; row < o.getNumRows(); row++) {
      for (int col = 0; col < o.getNumCols(); col++) {
        for (int band = 0; band < o.getNumBands(); band++) {
          sum += o.getValue(row, col, band);
        }
      }
    }
    return sum;
  }
Esempio n. 3
0
  public ArrayList vectorize(ImageData o) {
    ArrayList list = new ArrayList();

    for (int row = 0; row < o.getNumRows(); row++) {
      for (int col = 0; col < o.getNumCols(); col++) {
        for (int band = 0; band < o.getNumBands(); band++) {
          list.add(new Double(o.getValue(row, col, band)));
        }
      }
    }

    return list;
  }