Search in sources :

Example 6 with GrayU8

use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.

the class TestWrapFHtoInterestPoint method standard.

@Test
public void standard() {
    WrapFHtoInterestPoint alg = new WrapFHtoInterestPoint(detector);
    new GeneralInterestPointDetectorChecks(alg, false, true, GrayU8.class) {
    }.performAllTests();
}
Also used : WrapFHtoInterestPoint(boofcv.abst.feature.detect.interest.WrapFHtoInterestPoint) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 7 with GrayU8

use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.

the class ColorYuv method ycbcrToRgb_U8.

/**
 * Conversion from YCbCr to RGB.
 *
 * NOTE: Input and output image can be the same instance.
 *
 * @param yuv YCbCr encoded 8-bit image
 * @param rgb RGB encoded 8-bit image
 */
public static void ycbcrToRgb_U8(Planar<GrayU8> yuv, Planar<GrayU8> rgb) {
    GrayU8 Y = yuv.getBand(0);
    GrayU8 U = yuv.getBand(1);
    GrayU8 V = yuv.getBand(2);
    GrayU8 R = rgb.getBand(0);
    GrayU8 G = rgb.getBand(1);
    GrayU8 B = rgb.getBand(2);
    for (int row = 0; row < yuv.height; row++) {
        int indexYuv = yuv.startIndex + row * yuv.stride;
        int indexRgb = rgb.startIndex + row * rgb.stride;
        for (int col = 0; col < yuv.width; col++, indexYuv++, indexRgb++) {
            int y = 1191 * ((Y.data[indexYuv] & 0xFF) - 16);
            int cb = (U.data[indexYuv] & 0xFF) - 128;
            int cr = (V.data[indexYuv] & 0xFF) - 128;
            if (y < 0)
                y = 0;
            int r = (y + 1836 * cr) >> 10;
            int g = (y - 547 * cr - 218 * cb) >> 10;
            int b = (y + 2165 * cb) >> 10;
            if (r < 0)
                r = 0;
            else if (r > 255)
                r = 255;
            if (g < 0)
                g = 0;
            else if (g > 255)
                g = 255;
            if (b < 0)
                b = 0;
            else if (b > 255)
                b = 255;
            R.data[indexRgb] = (byte) r;
            G.data[indexRgb] = (byte) g;
            B.data[indexRgb] = (byte) b;
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8)

Example 8 with GrayU8

use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.

the class BinaryImageOps method erode4.

/**
 * <p>
 * Erodes an image according to a 4-neighborhood.  Unless a pixel is connected to all its neighbors its value
 * is set to zero.
 * </p>
 *
 * @param input  Input image. Not modified.
 * @param numTimes How many times the operation will be applied to the image.
 * @param output If not null, the output image.  If null a new image is declared and returned.  Modified.
 * @return Output image.
 */
public static GrayU8 erode4(GrayU8 input, int numTimes, GrayU8 output) {
    output = InputSanityCheck.checkDeclare(input, output);
    if (numTimes <= 0)
        throw new IllegalArgumentException("numTimes must be >= 1");
    ImplBinaryInnerOps.erode4(input, output);
    ImplBinaryBorderOps.erode4(input, output);
    if (numTimes > 1) {
        GrayU8 tmp1 = new GrayU8(input.width, input.height);
        GrayU8 tmp2 = output;
        for (int i = 1; i < numTimes; i++) {
            ImplBinaryInnerOps.erode4(tmp2, tmp1);
            ImplBinaryBorderOps.erode4(tmp2, tmp1);
            GrayU8 a = tmp1;
            tmp1 = tmp2;
            tmp2 = a;
        }
        if (tmp2 != output) {
            output.setTo(tmp2);
        }
    }
    return output;
}
Also used : GrayU8(boofcv.struct.image.GrayU8)

Example 9 with GrayU8

use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.

the class BinaryImageOps method dilate4.

/**
 * <p>
 * Dilates an image according to a 4-neighborhood.  If a pixel is connected to any other pixel then its output
 * value will be one.
 * </p>
 *
 * @param input  Input image. Not modified.
 * @param numTimes How many times the operation will be applied to the image.
 * @param output If not null, the output image.  If null a new image is declared and returned.  Modified.
 * @return Output image.
 */
public static GrayU8 dilate4(GrayU8 input, int numTimes, GrayU8 output) {
    output = InputSanityCheck.checkDeclare(input, output);
    ImplBinaryInnerOps.dilate4(input, output);
    ImplBinaryBorderOps.dilate4(input, output);
    if (numTimes > 1) {
        GrayU8 tmp1 = new GrayU8(input.width, input.height);
        GrayU8 tmp2 = output;
        for (int i = 1; i < numTimes; i++) {
            ImplBinaryInnerOps.dilate4(tmp2, tmp1);
            ImplBinaryBorderOps.dilate4(tmp2, tmp1);
            GrayU8 a = tmp1;
            tmp1 = tmp2;
            tmp2 = a;
        }
        if (tmp2 != output) {
            output.setTo(tmp2);
        }
    }
    return output;
}
Also used : GrayU8(boofcv.struct.image.GrayU8)

Example 10 with GrayU8

use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.

the class BinaryImageOps method erode8.

/**
 * <p>
 * Erodes an image according to a 8-neighborhood.  Unless a pixel is connected to all its neighbors its value
 * is set to zero.
 * </p>
 *
 * @param input  Input image. Not modified.
 * @param numTimes How many times the operation will be applied to the image.
 * @param output If not null, the output image.  If null a new image is declared and returned.  Modified.
 * @return Output image.
 */
public static GrayU8 erode8(GrayU8 input, int numTimes, GrayU8 output) {
    output = InputSanityCheck.checkDeclare(input, output);
    ImplBinaryInnerOps.erode8(input, output);
    ImplBinaryBorderOps.erode8(input, output);
    if (numTimes > 1) {
        GrayU8 tmp1 = new GrayU8(input.width, input.height);
        GrayU8 tmp2 = output;
        for (int i = 1; i < numTimes; i++) {
            ImplBinaryInnerOps.erode8(tmp2, tmp1);
            ImplBinaryBorderOps.erode8(tmp2, tmp1);
            GrayU8 a = tmp1;
            tmp1 = tmp2;
            tmp2 = a;
        }
        if (tmp2 != output) {
            output.setTo(tmp2);
        }
    }
    return output;
}
Also used : GrayU8(boofcv.struct.image.GrayU8)

Aggregations

GrayU8 (boofcv.struct.image.GrayU8)417 Test (org.junit.Test)242 BufferedImage (java.awt.image.BufferedImage)53 GrayS32 (boofcv.struct.image.GrayS32)52 GrayF32 (boofcv.struct.image.GrayF32)49 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)48 GrayS16 (boofcv.struct.image.GrayS16)45 Planar (boofcv.struct.image.Planar)28 ArrayList (java.util.ArrayList)22 File (java.io.File)17 ListDisplayPanel (boofcv.gui.ListDisplayPanel)16 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)16 ImageGray (boofcv.struct.image.ImageGray)15 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)15 Random (java.util.Random)14 Point2D_F64 (georegression.struct.point.Point2D_F64)11 ImageRectangle (boofcv.struct.ImageRectangle)10 GrayU16 (boofcv.struct.image.GrayU16)10 Se3_F64 (georegression.struct.se.Se3_F64)10 Point3D_F64 (georegression.struct.point.Point3D_F64)9