use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class DistortImageOps method affine.
/**
* <p>
* Applies an affine transformation from the input image to the output image.
* </p>
*
* <p>
* Input coordinates (x,y) to output coordinate (x',y')<br>
* x' = a11*x + a12*y + dx<br>
* y' = a21*x + a22*y + dy
* </p>
* @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 <T extends ImageBase<T>> void affine(T input, T output, BorderType borderType, InterpolationType 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 ImageGray) {
distortSingle((ImageGray) input, (ImageGray) output, model, interpType, borderType);
} else if (input instanceof Planar) {
distortPL((Planar) input, (Planar) output, model, borderType, interpType);
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class DistortImageOps method rotate.
/**
* <p>
* Rotates the image using the specified interpolation type. The rotation is performed
* around the specified center of rotation in the input image.
* </p>
*
* <p>
* Input coordinates (x,y) to output coordinate (x',y')<br>
* x' = x_c + c*(x-x_c) - s(y - y_c)<br>
* y' = y_c + s*(x-x_c) + c(y - y_c)
* </p>
*
* @deprecated As of v0.19. Use {@link FDistort} instead
*
* @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.
* @param angleInputToOutput Angle of rotation in radians. From input to output, CCW rotation.
*/
@Deprecated
public static <T extends ImageBase<T>> void rotate(T input, T output, BorderType borderType, InterpolationType interpType, float angleInputToOutput) {
// (output.width+1)%2;
float offX = 0;
// (output.height+1)%2;
float offY = 0;
PixelTransform2_F32 model = DistortSupport.transformRotate(input.width / 2, input.height / 2, output.width / 2 - offX, output.height / 2 - offY, angleInputToOutput);
if (input instanceof ImageGray) {
distortSingle((ImageGray) input, (ImageGray) output, model, interpType, borderType);
} else if (input instanceof Planar) {
distortPL((Planar) input, (Planar) output, model, borderType, interpType);
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method localGaussian.
@Test
public void localGaussian() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("localGaussian"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 200);
BoofTesting.checkSubImage(this, "performLocalGaussian", true, m, input, output);
total++;
}
assertEquals(2, total);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method naiveLocalSquare.
public void naiveLocalSquare(ImageGray input, GrayU8 output, int radius, double scale, boolean down) {
ImageGray blur;
boolean isInt;
if (input instanceof GrayU8) {
isInt = true;
blur = BlurImageOps.mean((GrayU8) input, null, radius, null);
} else {
isInt = false;
blur = BlurImageOps.mean((GrayF32) input, null, radius, null);
}
float fscale = (float) scale;
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
double threshold = GeneralizedImageOps.get(blur, x, y);
double v = GeneralizedImageOps.get(input, x, y);
boolean one;
if (down) {
if (isInt) {
one = (int) v <= ((int) threshold) * fscale;
} else {
one = v <= threshold * fscale;
}
} else {
if (isInt) {
one = ((int) v) * fscale > (int) threshold;
} else {
one = v * fscale > threshold;
}
}
if (one) {
output.set(x, y, 1);
} else {
output.set(x, y, 0);
}
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method threshold.
@Test
public void threshold() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("threshold"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageGray a = FactoryGImageGray.wrap(input);
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
a.set(x, y, x);
}
}
BoofTesting.checkSubImage(this, "performThreshold", true, m, input, output);
total++;
}
assertEquals(6, total);
}
Aggregations