Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2011-2015, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package boofcv.alg.distort;
import boofcv.abst.distort.FDistort;
import boofcv.alg.distort.impl.DistortSupport;
import boofcv.alg.interpolate.InterpolatePixelS;
import boofcv.alg.interpolate.TypeInterpolate;
import boofcv.core.image.border.BorderType;
import boofcv.factory.distort.FactoryDistort;
import boofcv.factory.interpolate.FactoryInterpolation;
import boofcv.struct.ImageRectangle_F32;
import boofcv.struct.ImageRectangle_F64;
import boofcv.struct.distort.PixelTransform_F32;
import boofcv.struct.distort.PixelTransform_F64;
import boofcv.struct.distort.PointTransform_F32;
import boofcv.struct.image.ImageBase;
import boofcv.struct.image.ImageSingleBand;
import boofcv.struct.image.MultiSpectral;
import georegression.struct.affine.Affine2D_F32;
import georegression.struct.shapes.RectangleLength2D_F32;
import georegression.struct.shapes.RectangleLength2D_F64;
import georegression.struct.shapes.RectangleLength2D_I32;
/**
*
* Provides common function for distorting images.
*
*
* @author Peter Abeles
*/
public class DistortImageOps {
/**
*
* Applies an affine transformation from the input image to the output image.
*
* @param input Which which is being rotated.
* @param output The image in which the output is written to.
* @param borderType Describes how pixels outside the image border should be handled.
* @param interpType Which type of interpolation will be used.
*
* @deprecated As of v0.19. Use {@link FDistort} instead
*/
@Deprecated
public static
void affine(T input, T output, BorderType borderType, TypeInterpolate interpType,
double a11, double a12, double a21, double a22,
double dx, double dy)
{
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 = m.invert(null);
PixelTransformAffine_F32 model = new PixelTransformAffine_F32(m);
if( input instanceof ImageSingleBand ) {
distortSingle((ImageSingleBand)input, (ImageSingleBand)output, model, interpType, borderType);
} else if( input instanceof MultiSpectral ) {
distortMS((MultiSpectral) input, (MultiSpectral) output, model, borderType, interpType);
}
}
/**
* Applies a pixel transform to a single band image. Easier to use function.
*
* @deprecated As of v0.19. Use {@link FDistort} instead
*
* @param input Input (source) image.
* @param output Where the result of transforming the image image is written to.
* @param transform The transform that is being applied to the image
* @param interpType Which type of pixel interpolation should be used. BILINEAR is in general recommended
* @param borderType Specifies how to handle image borders.
*/
public static
void distortSingle(Input input, Output output,
PixelTransform_F32 transform,
TypeInterpolate interpType, BorderType borderType)
{
boolean skip = borderType == BorderType.SKIP;
if( skip )
borderType = BorderType.EXTENDED;
Class inputType = (Class)input.getClass();
Class