Search in sources :

Example 1 with ImageGray

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);
    }
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) Planar(boofcv.struct.image.Planar) ImageGray(boofcv.struct.image.ImageGray)

Example 2 with ImageGray

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);
    }
}
Also used : Planar(boofcv.struct.image.Planar) ImageGray(boofcv.struct.image.ImageGray) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32)

Example 3 with ImageGray

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);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 4 with ImageGray

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);
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8)

Example 5 with ImageGray

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);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayU8(boofcv.struct.image.GrayU8) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

ImageGray (boofcv.struct.image.ImageGray)168 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)56 GImageGray (boofcv.core.image.GImageGray)56 Test (org.junit.jupiter.api.Test)28 GrayF32 (boofcv.struct.image.GrayF32)27 Method (java.lang.reflect.Method)27 GrayU8 (boofcv.struct.image.GrayU8)26 Test (org.junit.Test)12 Planar (boofcv.struct.image.Planar)9 GrayS32 (boofcv.struct.image.GrayS32)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)5 FactoryImageBorder (boofcv.core.image.border.FactoryImageBorder)5 ImageRectangle (boofcv.struct.ImageRectangle)5 ImageBorder (boofcv.struct.border.ImageBorder)5 Bitmap (android.graphics.Bitmap)4 ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)4 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)4 GrayS16 (boofcv.struct.image.GrayS16)4 ImageInterleaved (boofcv.struct.image.ImageInterleaved)3