use of boofcv.struct.image.InterleavedU8 in project BoofCV by lessthanoptimal.
the class TestConvolveNormalizedNaive_IL method convolve.
/**
* Check it against one specific type to see if the core algorithm is correct
*/
@Test
void convolve() {
Kernel2D_S32 kernel = FactoryKernel.random2D_I32(7, 3, 0, 20, rand);
kernel.offset = 1;
InterleavedU8 input = new InterleavedU8(width, height, numBands);
ImageMiscOps.fillUniform(input, rand, 0, 50);
InterleavedU8 output = new InterleavedU8(width, height, numBands);
ConvolveNormalizedNaive_IL.convolve(kernel, input, output);
for (int y = 0; y < output.height; y++) {
for (int x = 0; x < output.width; x++) {
for (int band = 0; band < numBands; band++) {
int expected = convolve(x, y, band, kernel, input);
int found = output.getBand(x, y, band);
assertEquals(expected, found);
}
}
}
}
use of boofcv.struct.image.InterleavedU8 in project BoofCV by lessthanoptimal.
the class TestConvolveNormalizedNaive_IL method horizontal.
/**
* Check it against one specific type to see if the core algorithm is correct
*/
@Test
void horizontal() {
Kernel1D_S32 kernel = new Kernel1D_S32(new int[] { 1, 2, 3, 4, 5, 6 }, 6, 4);
InterleavedU8 input = new InterleavedU8(width, height, numBands);
ImageMiscOps.fillUniform(input, rand, 0, 50);
InterleavedU8 output = new InterleavedU8(width, height, numBands);
ConvolveNormalizedNaive_IL.horizontal(kernel, input, output);
for (int y = 0; y < output.height; y++) {
for (int x = 0; x < output.width; x++) {
for (int band = 0; band < numBands; band++) {
int expected = horizontal(x, y, band, kernel, input);
int found = output.getBand(x, y, band);
assertEquals(expected, found);
}
}
}
}
use of boofcv.struct.image.InterleavedU8 in project BoofCV by lessthanoptimal.
the class FilePreviewChooser method loadVideoPreview.
@Nullable
private BufferedImage loadVideoPreview(String path) {
BufferedImage full = null;
try {
SimpleImageSequence<InterleavedU8> sequence = Objects.requireNonNull(DefaultMediaManager.INSTANCE.openVideo(path, ImageType.IL_U8));
if (sequence.hasNext()) {
InterleavedU8 frame = sequence.next();
full = ConvertBufferedImage.convertTo(frame, null, true);
}
} catch (RuntimeException ignore) {
}
return full;
}
use of boofcv.struct.image.InterleavedU8 in project BoofCV by lessthanoptimal.
the class TestConvolveNormalizedNaive_IL method vertical.
/**
* Check it against one specific type to see if the core algorithm is correct
*/
@Test
void vertical() {
Kernel1D_S32 kernel = new Kernel1D_S32(new int[] { 1, 2, 3, 4, 5, 6 }, 6, 4);
InterleavedU8 input = new InterleavedU8(width, height, numBands);
ImageMiscOps.fillUniform(input, rand, 0, 50);
InterleavedU8 output = new InterleavedU8(width, height, numBands);
ConvolveNormalizedNaive_IL.vertical(kernel, input, output);
for (int y = 0; y < output.height; y++) {
for (int x = 0; x < output.width; x++) {
for (int band = 0; band < numBands; band++) {
int expected = vertical(x, y, band, kernel, input);
int found = output.getBand(x, y, band);
assertEquals(expected, found);
}
}
}
}
use of boofcv.struct.image.InterleavedU8 in project BoofCV by lessthanoptimal.
the class TestConvolveNormalizedNaive_IL method vertical2_U16_U8.
/**
* Check it against one specific type to see if the core algorithm is correct
*/
@Test
void vertical2_U16_U8() {
Kernel1D_S32 kernelY = new Kernel1D_S32(new int[] { 1, 2, 3, 4, 5, 6 }, 6, 4);
Kernel1D_S32 kernelX = new Kernel1D_S32(new int[] { 4, 2, 1, 4, 3, 6 }, 5, 2);
InterleavedU16 input = new InterleavedU16(width, height, numBands);
ImageMiscOps.fillUniform(input, rand, 0, 80);
InterleavedU8 output = new InterleavedU8(width, height, numBands);
ConvolveNormalizedNaive_IL.vertical(kernelX, kernelY, input, output);
InterleavedU8 alt = new InterleavedU8(width, height, numBands);
ConvolveImageNoBorder.vertical(kernelY, input, alt, kernelX.computeSum() * kernelY.computeSum());
for (int y = 0; y < output.height; y++) {
for (int x = 0; x < output.width; x++) {
for (int band = 0; band < numBands; band++) {
int expected = vertical2(x, y, band, kernelX, kernelY, input);
int found = output.getBand(x, y, band);
assertEquals(expected, found);
}
}
}
}
Aggregations