org.openimaj.math.geometry.shape.Rectangle.overlapping()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(69)

本文整理了Java中org.openimaj.math.geometry.shape.Rectangle.overlapping方法的一些代码示例,展示了Rectangle.overlapping的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.overlapping方法的具体详情如下:
包路径:org.openimaj.math.geometry.shape.Rectangle
类名称:Rectangle
方法名:overlapping

Rectangle.overlapping介绍

[英]Get the overlapping rectangle between this rectangle and another.
[中]获取这个矩形和另一个矩形之间的重叠矩形。

代码示例

代码示例来源:origin: openimaj/openimaj

/**
 * Compute the percentage by which the given rectangle overlaps this one.
 *
 * @param other
 * @return the percentage overlap
 */
public double percentageOverlap(Rectangle other) {
  final Rectangle overlap = overlapping(other);
  if (overlap == null)
    return 0;
  return (overlap.calculateArea() / calculateArea());
}

代码示例来源:origin: openimaj/openimaj

/**
 * {@link Rectangle#overlapping(Rectangle)} called and normalised by:
 * 
 * @param A
 * @param B
 * @return intersect / (areaA + areaB - intersect)
 */
public static float tldOverlapNorm(Rectangle A, Rectangle B) {
  Rectangle overlap = A.overlapping(B);
  double intersect = overlap == null ? 0 : overlap.calculateArea();
  double areaA = A.calculateArea();
  double areaB = B.calculateArea();
  
  return (float) (intersect / (areaA + areaB - intersect));
}

代码示例来源:origin: openimaj/openimaj

@Override
public double intersectionArea(Shape that, int nStepsPerDimention) {
  final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
  if (overlapping == null)
    return 0;
  double intersection = 0;
  final double step = Math.max(overlapping.width, overlapping.height) / (double) nStepsPerDimention;
  double nReads = 0;
  for (float x = overlapping.x; x < overlapping.x + overlapping.width; x += step) {
    for (float y = overlapping.y; y < overlapping.y + overlapping.height; y += step) {
      final boolean insideThis = this.isInside(new Point2dImpl(x, y));
      final boolean insideThat = that.isInside(new Point2dImpl(x, y));
      nReads++;
      if (insideThis && insideThat) {
        intersection++;
      }
    }
  }
  return (intersection / nReads) * (overlapping.width * overlapping.height);
}

代码示例来源:origin: openimaj/openimaj

@Override
public double intersectionArea(Shape that, int nStepsPerDimention) {
  final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
  if (overlapping == null)
    return 0;
  double intersection = 0;
  final double step = Math.max(overlapping.width, overlapping.height) / (double) nStepsPerDimention;
  double nReads = 0;
  for (float x = overlapping.x; x < overlapping.x + overlapping.width; x += step) {
    for (float y = overlapping.y; y < overlapping.y + overlapping.height; y += step) {
      final boolean insideThis = this.isInside(new Point2dImpl(x, y));
      final boolean insideThat = that.isInside(new Point2dImpl(x, y));
      nReads++;
      if (insideThis && insideThat) {
        intersection++;
      }
    }
  }
  return (intersection / nReads) * (overlapping.width * overlapping.height);
}

代码示例来源:origin: openimaj/openimaj

final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
if (overlapping == null)
  return 0;

代码示例来源:origin: openimaj/openimaj

@Override
public double intersectionArea(Shape that, int nStepsPerDimension) {
  final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
  if (overlapping == null)
    return 0;
  if (that instanceof Rectangle) {
    // Special case
    return overlapping.calculateArea();
  } else {
    double intersection = 0;
    final double step = Math.max(overlapping.width, overlapping.height) / (double) nStepsPerDimension;
    double nReads = 0;
    for (float x = overlapping.x; x < overlapping.x + overlapping.width; x += step) {
      for (float y = overlapping.y; y < overlapping.y + overlapping.height; y += step) {
        final boolean insideThis = this.isInside(new Point2dImpl(x, y));
        final boolean insideThat = that.isInside(new Point2dImpl(x, y));
        nReads++;
        if (insideThis && insideThat) {
          intersection++;
        }
      }
    }
    return (intersection / nReads) * (overlapping.width * overlapping.height);
  }
}

代码示例来源:origin: openimaj/openimaj

searchAreaBounds.scaleCentroid(searchAreaSize);
if (searchAreaBounds.overlapping(this.small_.getBounds()) != null)
  searchAreaBounds = searchAreaBounds.overlapping(this.small_.getBounds());
else
  searchAreaBounds = this.small_.getBounds();

相关文章