예제 #1
0
  /**
   * Finds the maximum area axis-aligned rectangle contained inside the transformed image which does
   * not include any pixels outside the sources border. Assumes that the coordinates are not flipped
   * and some other stuff too.
   *
   * @param srcWidth Width of the source image
   * @param srcHeight Height of the source image
   * @param transform Transform being applied to the image
   * @return Bounding box
   */
  public static Rectangle2D_F32 boundBoxInside(
      int srcWidth, int srcHeight, PixelTransform_F32 transform) {

    float x0, y0, x1, y1;

    transform.compute(0, 0);
    x0 = transform.distX;
    y0 = transform.distY;

    transform.compute(srcWidth, 0);
    x1 = transform.distX;
    transform.compute(0, srcHeight);
    y1 = transform.distY;

    for (int x = 0; x < srcWidth; x++) {
      transform.compute(x, 0);
      if (transform.distY > y0) y0 = transform.distY;
      transform.compute(x, srcHeight);
      if (transform.distY < y1) y1 = transform.distY;
    }

    for (int y = 0; y < srcHeight; y++) {
      transform.compute(0, y);
      if (transform.distX > x0) x0 = transform.distX;
      transform.compute(srcWidth, y);
      if (transform.distX < x1) x1 = transform.distX;
    }

    return new Rectangle2D_F32(x0, y0, x1 - x0, y1 - y0);
  }
예제 #2
0
 @Override
 public float unsafe_getF(int x, int y) {
   transform.compute(x, y);
   return interpolate.get(transform.distX, transform.distY);
 }
예제 #3
0
 @Override
 public Number get(int x, int y) {
   transform.compute(x, y);
   return interpolate.get(transform.distX, transform.distY);
 }