use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class TestTldVarianceFilter method selectThreshold.
@Test
public void selectThreshold() {
GrayU8 image = new GrayU8(50, 80);
ImageMiscOps.fillUniform(image, rand, 0, 200);
TldVarianceFilter alg = new TldVarianceFilter(GrayU8.class);
alg.setImage(image);
alg.selectThreshold(new ImageRectangle(10, 8, 21, 33));
double found = alg.getThresholdLower();
double expected = computeVariance(image, 10, 8, 21, 33) / 2.0;
assertEquals(expected, found, 1e-8);
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class IntegralImageOps method print.
/**
* Prints out the kernel.
*
* @param kernel THe kernel which is to be printed.
*/
public static void print(IntegralKernel kernel) {
int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
for (ImageRectangle k : kernel.blocks) {
if (k.x0 < x0)
x0 = k.x0;
if (k.y0 < y0)
y0 = k.y0;
if (k.x1 > x1)
x1 = k.x1;
if (k.y1 > y1)
y1 = k.y1;
}
int w = x1 - x0;
int h = y1 - y0;
int[] sum = new int[w * h];
for (int i = 0; i < kernel.blocks.length; i++) {
ImageRectangle r = kernel.blocks[i];
int value = kernel.scales[i];
for (int y = r.y0; y < r.y1; y++) {
int yy = y - y0;
for (int x = r.x0; x < r.x1; x++) {
int xx = x - x0;
sum[yy * w + xx] += value;
}
}
}
System.out.println("IntegralKernel: TL = (" + (x0 + 1) + "," + (y0 + 1) + ") BR=(" + x1 + "," + y1 + ")");
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
System.out.printf("%4d ", sum[y * w + x]);
}
System.out.println();
}
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class ImplIntegralImageOps method convolveSparse.
public static float convolveSparse(GrayF32 integral, IntegralKernel kernel, int x, int y) {
float ret = 0;
int N = kernel.getNumBlocks();
for (int i = 0; i < N; i++) {
ImageRectangle r = kernel.blocks[i];
ret += block_zero(integral, x + r.x0, y + r.y0, x + r.x1, y + r.y1) * kernel.scales[i];
}
return ret;
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class ImplIntegralImageOps method convolveSparse.
public static double convolveSparse(GrayF64 integral, IntegralKernel kernel, int x, int y) {
double ret = 0;
int N = kernel.getNumBlocks();
for (int i = 0; i < N; i++) {
ImageRectangle r = kernel.blocks[i];
ret += block_zero(integral, x + r.x0, y + r.y0, x + r.x1, y + r.y1) * kernel.scales[i];
}
return ret;
}
use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.
the class ImplIntegralImageOps method convolve.
public static void convolve(GrayS32 integral, IntegralKernel kernel, GrayS32 output) {
for (int y = 0; y < integral.height; y++) {
for (int x = 0; x < integral.width; x++) {
int total = 0;
for (int i = 0; i < kernel.blocks.length; i++) {
ImageRectangle b = kernel.blocks[i];
total += block_zero(integral, x + b.x0, y + b.y0, x + b.x1, y + b.y1) * kernel.scales[i];
}
output.set(x, y, total);
}
}
}
Aggregations