/** * Used to manually specify a transform. From output to input */ public FDistort transform( Point2Transform2_F32 outputToInput ) { return transform( new PointToPixelTransform_F32(outputToInput)); }
/** * Applies a distortion which will rotate the input image by the specified amount. */ public FDistort rotate( double angleInputToOutput ) { PixelTransform2_F32 outputToInput = DistortSupport.transformRotate(input.width/2,input.height/2, output.width/2,output.height/2,(float)angleInputToOutput); return transform(outputToInput); }
/** * <p>Applies a distortion which will rescale the input image into the output image. You * might want to consider using {@link #scaleExt()} instead since it sets the border behavior * to extended, which is probably what you want to do.</p> * * NOTE: Checks to see if it can recycle the previous transform and update it with a new affine model * to avoid declaring new memory. */ public FDistort scale() { if( outputToInput != null && outputToInput instanceof PixelTransformAffine_F32 ) { PixelTransformAffine_F32 affine = (PixelTransformAffine_F32)outputToInput; DistortSupport.transformScale(output, input, affine); return this; } else { return transform(DistortSupport.transformScale(output, input, null)); } }
/** * Constructor which specifies the characteristics of the undistorted image * * @param width Width of undistorted image * @param height Height of undistorted image * @param imageType Type of undistorted image */ public RemovePerspectiveDistortion( int width , int height , ImageType<T> imageType ) { this(width,height); output = imageType.createImage(width,height); distort = new FDistort(imageType); distort.output(output); distort.interp(InterpolationType.BILINEAR).transform(transform); }
/** * Constructor which specifies the characteristics of the undistorted image * * @param width Width of undistorted image * @param height Height of undistorted image * @param imageType Type of undistorted image */ public RemovePerspectiveDistortion( int width , int height , ImageType<T> imageType ) { output = imageType.createImage(width,height); distort = new FDistort(imageType); distort.output(output); distort.interp(InterpolationType.BILINEAR).transform(homography); for (int i = 0; i < 4; i++) { associatedPairs.add( new AssociatedPair()); } associatedPairs.get(0).p1.set(0,0); associatedPairs.get(1).p1.set(output.width-1,0); associatedPairs.get(2).p1.set(output.width-1,output.height-1); associatedPairs.get(3).p1.set(0,output.height-1); }
/** * Affine transform from input to output */ public FDistort affine(double a11, double a12, double a21, double a22, double dx, double dy) { PixelTransformAffine_F32 transform; if( outputToInput != null && outputToInput instanceof PixelTransformAffine_F32 ) { transform = (PixelTransformAffine_F32)outputToInput; } else { transform = new PixelTransformAffine_F32(); } Affine2D_F32 m = new Affine2D_F32(); m.a11 = (float)a11; m.a12 = (float)a12; m.a21 = (float)a21; m.a22 = (float)a22; m.tx = (float)dx; m.ty = (float)dy; m.invert(transform.getModel()); return transform(transform); }