Search in sources :

Example 81 with GrayU8

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

the class TestUtilImageIO method loadImage_saveImage_PPM.

@Test
public void loadImage_saveImage_PPM() throws IOException {
    Planar<GrayU8> orig = new Planar<>(GrayU8.class, width, height, 3);
    GImageMiscOps.fillUniform(orig, rand, 0, 256);
    File temp = File.createTempFile("temp", ".png");
    UtilImageIO.savePPM(orig, temp.getPath(), null);
    Planar<GrayU8> found = UtilImageIO.loadPPM_U8(temp.getPath(), null, null);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            for (int k = 0; k < 3; k++) assertEquals(orig.getBand(k).get(x, y), found.getBand(k).get(x, y));
        }
    }
    // clean up
    // no assertTrue() here because in windows it will fail
    temp.delete();
}
Also used : Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) File(java.io.File) Test(org.junit.Test)

Example 82 with GrayU8

use of boofcv.struct.image.GrayU8 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 83 with GrayU8

use of boofcv.struct.image.GrayU8 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)

Example 84 with GrayU8

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

the class TestConvolveImageStandardSparse method checkMethod.

private void checkMethod(Method method, int width, int height, int kernelOffset, int kernelWidth, Random rand) {
    GrayU8 seedImage = new GrayU8(width, height);
    ImageMiscOps.fillUniform(seedImage, rand, 0, 255);
    // creates a floating point image with integer elements
    GrayF32 floatImage = new GrayF32(width, height);
    ConvertImage.convert(seedImage, floatImage);
    sumKernel = 0;
    kernelI32 = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, -1, kernelWidth / 2);
    kernelF32 = new Kernel1D_F32(kernelI32.width);
    for (int i = 0; i < kernelI32.width; i++) {
        sumKernel += kernelF32.data[i] = kernelI32.data[i];
    }
    kernelI32.offset = kernelOffset;
    kernelF32.offset = kernelOffset;
    boolean isFloatingKernel = method.getParameterTypes()[0] == Kernel1D_F32.class;
    boolean isDivisor = method.getParameterTypes().length != 6;
    expectedOutput = computeExpected(seedImage, !isFloatingKernel, isDivisor);
    ImageGray inputImage = GeneralizedImageOps.convert(floatImage, null, (Class) method.getParameterTypes()[2]);
    Object inputKernel = isFloatingKernel ? kernelF32 : kernelI32;
    Object inputStorage = isFloatingKernel ? new float[kernelI32.width] : new int[kernelI32.width];
    checkResults(method, inputKernel, inputImage, inputStorage);
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32) GrayU8(boofcv.struct.image.GrayU8) ImageGray(boofcv.struct.image.ImageGray)

Example 85 with GrayU8

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

the class TestGradientTwo0 method compareToConvolve_I8.

@Test
public void compareToConvolve_I8() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientTwo0.class.getMethod("process", GrayU8.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, GradientTwo0.kernelDeriv_I32, true);
    validator.setKernel(1, GradientTwo0.kernelDeriv_I32, false);
    GrayU8 input = new GrayU8(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayS16 derivX = new GrayS16(width, height);
    GrayS16 derivY = new GrayS16(width, height);
    validator.compare(input, derivX, derivY);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32) Test(org.junit.Test)

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