本文整理了Java中org.openimaj.math.geometry.shape.Rectangle.overlapping
方法的一些代码示例,展示了Rectangle.overlapping
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.overlapping
方法的具体详情如下:
包路径:org.openimaj.math.geometry.shape.Rectangle
类名称: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();
内容来源于网络,如有侵权,请联系作者删除!