use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class ColorTrackerObjectRectangleTests method render.
@Override
protected void render(double scale, double tranX, double tranY) {
// each region in the target region will have a different color. Allowing scale, translation, and rotation
// to be estimated using color information alone
Quadrilateral_F64 q = initRegion.copy();
// scale it down a bit so that there is a border
if (multiColor)
scale(q, 0.95);
Point2D_F64 ab = average(q.a, q.b);
Point2D_F64 bc = average(q.b, q.c);
Point2D_F64 cd = average(q.c, q.d);
Point2D_F64 da = average(q.d, q.a);
Point2D_F64 abcd = average(ab, cd);
Quadrilateral_F64 r0 = new Quadrilateral_F64(q.a, ab, abcd, da, true);
Quadrilateral_F64 r1 = new Quadrilateral_F64(ab, q.b, bc, abcd, true);
Quadrilateral_F64 r2 = new Quadrilateral_F64(abcd, bc, q.c, cd, true);
Quadrilateral_F64 r3 = new Quadrilateral_F64(da, abcd, cd, q.d, true);
Polygon2D_I32[] region = new Polygon2D_I32[4];
region[0] = setPolygon(r0);
region[1] = setPolygon(r1);
region[2] = setPolygon(r2);
region[3] = setPolygon(r3);
int[] band0 = new int[] { 100, 50, 176, 0 };
int[] band1 = new int[] { 150, 200, 240, 40 };
int[] band2 = new int[] { 20, 234, 176, 210 };
GImageMiscOps.fill(original, 0);
GImageMiscOps.fill(input, 0);
for (int i = 0; i < 4; i++) {
int colorIndex;
if (multiColor)
colorIndex = i;
else
colorIndex = 0;
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(0), band0[colorIndex]);
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(1), band1[colorIndex]);
TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(2), band2[colorIndex]);
}
new FDistort(original, input).affine(scale, 0, 0, scale, tranX, tranY).apply();
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class DisplayGaussianKernelApp method setActiveAlgorithm.
@Override
public void setActiveAlgorithm(String name, Object cookie) {
DerivType type = (DerivType) cookie;
panel.reset();
for (int radius = 1; radius <= 40; radius += 2) {
int maxOrder = Math.max(type.orderX, type.orderY);
double sigma = FactoryKernelGaussian.sigmaForRadius(radius, maxOrder);
Class typeKer1 = FactoryKernel.getKernelType(imageType, 1);
Kernel1D kerX = FactoryKernelGaussian.derivativeK(typeKer1, type.orderX, sigma, radius);
Kernel1D kerY = FactoryKernelGaussian.derivativeK(typeKer1, type.orderY, sigma, radius);
Kernel2D kernel = GKernelMath.convolve(kerY, kerX);
T smallImg = GKernelMath.convertToImage(kernel);
new FDistort(smallImg, largeImg).interpNN().scaleExt().apply();
double maxValue = GImageStatistics.maxAbs(largeImg);
BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
panel.addImage(out, String.format("%5d", radius));
}
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class DisplaySteerableBase method setActiveAlgorithm.
@Override
public void setActiveAlgorithm(String name, Object cookie) {
DisplayGaussianKernelApp.DerivType dt = (DisplayGaussianKernelApp.DerivType) cookie;
// add basis
SteerableKernel<K> steerable = createKernel(dt.orderX, dt.orderY);
basisPanel.reset();
for (int i = 0; i < steerable.getBasisSize(); i++) {
T smallImg = GKernelMath.convertToImage(steerable.getBasis(i));
new FDistort(smallImg, largeImg).scaleExt().interpNN().apply();
double maxValue = GImageStatistics.maxAbs(largeImg);
BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
basisPanel.addImage(out, "Basis " + i);
}
// add steered kernels
steerPanel.reset();
for (int i = 0; i <= 20; i++) {
double angle = Math.PI * i / 20.0;
K kernel = steerable.compute(angle);
T smallImg = GKernelMath.convertToImage(kernel);
new FDistort(smallImg, largeImg).scaleExt().interpNN().apply();
double maxValue = GImageStatistics.maxAbs(largeImg);
BufferedImage out = VisualizeImageData.colorizeSign(largeImg, null, maxValue);
steerPanel.addImage(out, String.format("%5d", (int) (180.0 * angle / Math.PI)));
}
repaint();
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class DemonstrationInterpolateScaleApp method applyScaling.
private void applyScaling() {
scaledImage.reshape(panel.getWidth(), panel.getHeight());
if (scaledImage.width <= 0 || scaledImage.height <= 0) {
return;
}
if (latestImage.width != 0 && latestImage.height != 0) {
new FDistort(latestImage, scaledImage).interp(interpType).border(BorderType.EXTENDED).scale().apply();
BufferedImage out = ConvertBufferedImage.convertTo(scaledImage, null, true);
panel.setImageUI(out);
panel.repaint();
}
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class SubpixelGridTargetDisplay method render.
private synchronized void render(Rectangle visibleRect) {
if (visibleRect.width == 0 || visibleRect.height == 0)
return;
if (transformed.width != visibleRect.width || transformed.height != visibleRect.height || workImage == null) {
transformed.reshape(visibleRect.width, visibleRect.height);
workImage = new BufferedImage(visibleRect.width, visibleRect.height, BufferedImage.TYPE_INT_RGB);
}
double x = -visibleRect.x;
double y = -visibleRect.y;
new FDistort(input, transformed).interpNN().affine(scale, 0, 0, scale, x, y).apply();
ConvertBufferedImage.convertTo(transformed, workImage, true);
}
Aggregations