use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TextureGrayTrackerObjectRectangleChecks method convexFill.
public static void convexFill(Polygon2D_I32 poly, GrayU8 image, double value) {
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (int i = 0; i < poly.size(); i++) {
Point2D_I32 p = poly.vertexes.data[i];
if (p.y < minY) {
minY = p.y;
} else if (p.y > maxY) {
maxY = p.y;
}
if (p.x < minX) {
minX = p.x;
} else if (p.x > maxX) {
maxX = p.x;
}
}
ImageRectangle bounds = new ImageRectangle(minX, minY, maxX, maxY);
BoofMiscOps.boundRectangleInside(image, bounds);
Point2D_F64 p = new Point2D_F64();
Polygon2D_F64 poly64 = new Polygon2D_F64(4);
for (int i = 0; i < 4; i++) poly64.vertexes.data[i].setTo(poly.vertexes.data[i].x, poly.vertexes.data[i].y);
for (int y = bounds.y0; y < bounds.y1; y++) {
p.y = y;
for (int x = bounds.x0; x < bounds.x1; x++) {
p.x = x;
if (Intersection2D_F64.containsConvex(poly64, p)) {
GeneralizedImageOps.set(image, x, y, value);
}
}
}
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class VideoSequenceSimulator method convexFill.
private void convexFill(Polygon2D_I32 poly, ImageGray image, double value) {
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (int i = 0; i < poly.size(); i++) {
Point2D_I32 p = poly.vertexes.data[i];
if (p.y < minY) {
minY = p.y;
} else if (p.y > maxY) {
maxY = p.y;
}
if (p.x < minX) {
minX = p.x;
} else if (p.x > maxX) {
maxX = p.x;
}
}
ImageRectangle bounds = new ImageRectangle(minX, minY, maxX, maxY);
BoofMiscOps.boundRectangleInside(image, bounds);
Point2D_F64 p = new Point2D_F64();
Polygon2D_F64 poly64 = new Polygon2D_F64(4);
for (int i = 0; i < 4; i++) poly64.vertexes.data[i].setTo(poly.vertexes.data[i].x, poly.vertexes.data[i].y);
for (int y = bounds.y0; y < bounds.y1; y++) {
p.y = y;
for (int x = bounds.x0; x < bounds.x1; x++) {
p.x = x;
if (Intersection2D_F64.containsConvex(poly64, p)) {
GeneralizedImageOps.set(image, x, y, value);
}
}
}
}
Aggregations