use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class ScaleSpacePyramidPointPanel method setLevel.
private synchronized void setLevel(int level) {
// System.out.println("level "+level);
if (level > 0 && ss != null) {
ImageGray small = (ImageGray) ss.getLayer(level - 1);
ImageGray enlarge = GeneralizedImageOps.createSingleBand(small.getClass(), ss.getInputWidth(), ss.getInputHeight());
new FDistort(small, enlarge).interpNN().apply();
// if the size isn't the same null it so a new image will be declared
if (levelImage != null && (levelImage.getWidth() != enlarge.width || levelImage.getHeight() != enlarge.height)) {
levelImage = null;
}
levelImage = ConvertBufferedImage.convertTo(enlarge, levelImage, true);
double scale = ss.getScale(level - 1);
levelPoints.clear();
for (ScalePoint p : points) {
if (p.scale == scale) {
levelPoints.add(p);
}
}
} else {
levelPoints.clear();
levelPoints.addAll(points);
}
this.activeLevel = level;
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class ImagePyramidPanel method scaleUpLayers.
private void scaleUpLayers() {
T l = pyramid.getLayer(0);
if (upscale == null) {
interp = (InterpolatePixelS<T>) FactoryInterpolation.nearestNeighborPixelS(l.getClass());
upscale = (T) l.createNew(l.width, l.height);
} else {
upscale.reshape(l.width, l.height);
}
int N = pyramid.getNumLayers();
for (int i = 0; i < N; i++) {
new FDistort(pyramid.getLayer(i), upscale).interpNN().scaleExt().apply();
BufferedImage b = ConvertBufferedImage.convertTo(upscale, null, true);
if (showScales)
addImage(b, String.format("%5.2f", pyramid.getScale(i)));
else
addImage(b, String.format("%5.2f", pyramid.getSigma(i)));
}
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class TestRemovePerspectiveDistortion method applyForwardTransform.
private void applyForwardTransform(GrayF32 expected, GrayF32 input, Point2D_F64 topLeft, Point2D_F64 topRight, Point2D_F64 bottomRight, Point2D_F64 bottomLeft) {
Estimate1ofEpipolar computeHomography = FactoryMultiView.computeHomographyDLT(true);
ArrayList<AssociatedPair> associatedPairs = new ArrayList<>();
associatedPairs.add(new AssociatedPair(topLeft, new Point2D_F64(0, 0)));
associatedPairs.add(new AssociatedPair(topRight, new Point2D_F64(expected.width - 1, 0)));
associatedPairs.add(new AssociatedPair(bottomRight, new Point2D_F64(expected.width - 1, expected.height - 1)));
associatedPairs.add(new AssociatedPair(bottomLeft, new Point2D_F64(0, expected.height - 1)));
DMatrixRMaj H = new DMatrixRMaj(3, 3);
computeHomography.process(associatedPairs, H);
FMatrixRMaj H32 = new FMatrixRMaj(3, 3);
ConvertMatrixData.convert(H, H32);
new FDistort(expected, input).transform(new PointTransformHomography_F32(H32)).apply();
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class DenseFlowApp method changeInput.
@Override
public synchronized void changeInput(String name, int index) {
BufferedImage image0 = media.openImage(inputRefs.get(index).getPath(0));
BufferedImage image1 = media.openImage(inputRefs.get(index).getPath(1));
// process at 1/2 resolution to make it faster
unscaled.reshape(image0.getWidth(), image1.getHeight());
input0.reshape(unscaled.width / 2, unscaled.height / 2);
input1.reshape(unscaled.width / 2, unscaled.height / 2);
flow.reshape(unscaled.width / 2, unscaled.height / 2);
ConvertBufferedImage.convertFrom(image0, unscaled, false);
new FDistort(unscaled, input0).scaleExt().apply();
ConvertBufferedImage.convertFrom(image1, unscaled, false);
new FDistort(unscaled, input1).scaleExt().apply();
converted0 = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
converted1 = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
visualized = new BufferedImage(input0.width, input0.height, BufferedImage.TYPE_INT_RGB);
ConvertBufferedImage.convertTo(input0, converted0, true);
ConvertBufferedImage.convertTo(input1, converted1, true);
hasInputImage = true;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
flowPanel.setPreferredSize(new Dimension(input0.width, input0.height));
flowPanel.setImage(visualized);
animationPanel.setPreferredSize(new Dimension(input0.width, input0.height));
animationPanel.setAnimation(converted0, converted1);
gui.revalidate();
}
});
doRefreshAll();
}
use of boofcv.abst.distort.FDistort in project BoofCV by lessthanoptimal.
the class IntensityFeaturePyramidApp method setActiveAlgorithm.
@Override
public void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
if (input == null) {
return;
}
if (indexFamily == 0) {
intensity = (GeneralFeatureIntensity<T, D>) cookie;
if (pyramid == null)
return;
} else if (indexFamily == 1) {
// setup the pyramid
double[] scales = new double[25];
for (int i = 0; i < scales.length; i++) {
scales[i] = Math.exp(i * 0.15);
}
if (((Number) cookie).intValue() == 0) {
pyramid = FactoryPyramid.scaleSpacePyramid(scales, imageType);
} else {
pyramid = FactoryPyramid.scaleSpace(scales, imageType);
}
if (workImage != null)
pyramid.process(workImage);
if (intensity == null)
return;
}
// setup the feature intensity
gui.reset();
BufferedImage b = VisualizeImageData.grayMagnitude(workImage, null, 255);
gui.addImage(b, "Gray Image");
final ProgressMonitor progressMonitor = new ProgressMonitor(this, "Computing Scale Space Pyramid Response", "", 0, pyramid.getNumLayers());
for (int i = 0; i < pyramid.getNumLayers() && !progressMonitor.isCanceled(); i++) {
double scale = pyramid.getSigma(i);
T scaledImage = pyramid.getLayer(i);
anyDerivative.setInput(scaledImage);
D derivX = anyDerivative.getDerivative(true);
D derivY = anyDerivative.getDerivative(false);
D derivXX = anyDerivative.getDerivative(true, true);
D derivYY = anyDerivative.getDerivative(false, false);
D derivXY = anyDerivative.getDerivative(true, false);
intensity.process(scaledImage, derivX, derivY, derivXX, derivYY, derivXY);
GrayF32 featureImg = intensity.getIntensity();
// scale it up to full resolution
new FDistort(featureImg, scaledIntensity).interpNN().scaleExt().apply();
// visualize the rescaled intensity
b = VisualizeImageData.colorizeSign(scaledIntensity, null, ImageStatistics.maxAbs(scaledIntensity));
gui.addImage(b, String.format("Scale %6.2f", scale));
final int progressStatus = i + 1;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressMonitor.setProgress(progressStatus);
}
});
}
gui.requestFocusInWindow();
}
Aggregations