Search in sources :

Example 96 with GrayF32

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

the class ImplConvertJCodecPicture method yuv420_to_PlRgb_F32.

public static void yuv420_to_PlRgb_F32(Picture input, Planar<GrayF32> output) {
    int[] Y = input.getPlaneData(0);
    int[] U = input.getPlaneData(1);
    int[] V = input.getPlaneData(2);
    GrayF32 R = output.getBand(0);
    GrayF32 G = output.getBand(1);
    GrayF32 B = output.getBand(2);
    final int yStride = output.width;
    final int uvStride = output.width / 2;
    for (int row = 0; row < output.height; row++) {
        int indexY = row * yStride;
        int indexUV = (row / 2) * uvStride;
        int indexOut = output.startIndex + row * output.stride;
        for (int col = 0; col < output.width; col++, indexOut++) {
            int y = 1191 * (Y[indexY++] & 0xFF) - 16;
            int cr = (U[indexUV] & 0xFF) - 128;
            int cb = (V[indexUV] & 0xFF) - 128;
            if (y < 0)
                y = 0;
            int b = (y + 1836 * cr) >> 10;
            int g = (y - 547 * cr - 218 * cb) >> 10;
            int r = (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[indexOut] = r;
            G.data[indexOut] = g;
            B.data[indexOut] = b;
            indexUV += col & 0x1;
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 97 with GrayF32

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

the class TestLoadFileImageSequence method checkLoop.

/**
 * See if it loads the expected number of files.
 */
@Test
public void checkLoop() {
    LoadFileImageSequence<GrayF32> alg = new LoadFileImageSequence<>(ImageType.single(GrayF32.class), imagePath, "png");
    alg.setLoop(true);
    assertTrue(alg.isLoop());
    int total = 0;
    while (alg.hasNext() && total < 6) {
        total++;
        GrayF32 image = alg.next();
        assertEquals(100, image.width);
        assertEquals(100, image.height);
        BufferedImage buff = alg.getGuiImage();
        assertEquals(100, buff.getWidth());
        assertEquals(100, buff.getHeight());
    }
    assertEquals(6, total);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.Test)

Example 98 with GrayF32

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

the class BenchmarkInterpolatePixel method main.

public static void main(String[] args) {
    imgInt8 = new GrayU8(imgWidth, imgHeight);
    imgFloat32 = new GrayF32(imgWidth, imgHeight);
    Random rand = new Random(234);
    ImageMiscOps.fillUniform(imgInt8, rand, 0, 100);
    ImageMiscOps.fillUniform(imgFloat32, rand, 0, 200);
    System.out.println("=========  Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
    System.out.println();
    ProfileOperation.printOpsPerSec(new Bilinear_Safe_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new Bilinear_UnSafe_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new NearestNeighbor_Safe_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new BilinearConvolution_Safe_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new Polynomial_Safe_F32(), TEST_TIME);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Random(java.util.Random) GrayU8(boofcv.struct.image.GrayU8)

Example 99 with GrayF32

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

the class FourierTransformNaive_F32 method inverse.

public static void inverse(GrayF32 inputR, GrayF32 inputI, GrayF32 outputR) {
    GrayF32 tempR = new GrayF32(inputR.width, inputR.height);
    GrayF32 tempI = new GrayF32(inputI.width, inputI.height);
    for (int y = 0; y < inputR.height; y++) {
        int index = inputR.startIndex + inputR.stride * y;
        transform(false, inputR.data, inputI.data, tempR.data, tempI.data, index, inputR.width);
    }
    float[] columnR0 = new float[inputR.height];
    float[] columnI0 = new float[inputR.height];
    float[] columnR1 = new float[inputR.height];
    for (int x = 0; x < inputR.width; x++) {
        // copy the column
        for (int y = 0; y < inputR.height; y++) {
            columnR0[y] = tempR.unsafe_get(x, y);
            columnI0[y] = tempI.unsafe_get(x, y);
        }
        inverse(columnR0, columnI0, columnR1, 0, inputR.height);
        // copy the results back
        for (int y = 0; y < inputR.height; y++) {
            outputR.unsafe_set(x, y, columnR1[y]);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 100 with GrayF32

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

the class BenchmarkConvertImage method main.

public static void main(String[] args) {
    imgSInt8 = new GrayU8(imgWidth, imgHeight);
    imgSInt16 = new GrayS16(imgWidth, imgHeight);
    imgUInt8 = new GrayU8(imgWidth, imgHeight);
    imgUInt16 = new GrayS16(imgWidth, imgHeight);
    imgFloat32 = new GrayF32(imgWidth, imgHeight);
    System.out.println("=========  Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
    System.out.println();
    System.out.printf("Float32 to Int8              %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Float32toInt8(), 1000, false));
    System.out.printf("Int8 to Float32 signed       %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int8ToFloat32(imgSInt8), 1000, false));
    System.out.printf("Int8 to Float32 unsigned     %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int8ToFloat32(imgUInt8), 1000, false));
    System.out.printf("Int16 to Float32 signed       %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int16ToFloat32(imgSInt16), 1000, false));
    System.out.printf("Int16 to Float32 unsigned     %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int16ToFloat32(imgUInt16), 1000, false));
    System.out.printf("Int16 to Int8 signed          %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int16ToInt8(imgSInt16), 1000, false));
    System.out.printf("Int16 to Int8 unsigned        %10.2f ops/sec\n", ProfileOperation.profileOpsPerSec(new Int16ToInt8(imgUInt16), 1000, false));
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13