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();
}
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);
}
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));
}
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);
}
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);
}
Aggregations