use of boofcv.struct.image.GrayF64 in project BoofCV by lessthanoptimal.
the class FourierTransformNaive_F64 method forward.
public static void forward(GrayF64 inputR, GrayF64 outputR, GrayF64 outputI) {
GrayF64 tempR = new GrayF64(inputR.width, inputR.height);
GrayF64 tempI = new GrayF64(outputI.width, outputI.height);
for (int y = 0; y < inputR.height; y++) {
int index = inputR.startIndex + inputR.stride * y;
forward(inputR.data, tempR.data, tempI.data, index, inputR.width);
}
double[] columnR0 = new double[inputR.height];
double[] columnI0 = new double[inputR.height];
double[] columnR1 = new double[inputR.height];
double[] columnI1 = new double[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);
}
transform(true, columnR0, columnI0, columnR1, columnI1, 0, inputR.height);
// copy the results back
for (int y = 0; y < inputR.height; y++) {
outputR.unsafe_set(x, y, columnR1[y]);
outputI.unsafe_set(x, y, columnI1[y]);
}
}
}
use of boofcv.struct.image.GrayF64 in project BoofCV by lessthanoptimal.
the class TestFourierTransformNaive_F64 method forward_reverse_image.
@Test
public void forward_reverse_image() {
GrayF64 input = new GrayF64(30, 40);
GrayF64 tranR = new GrayF64(30, 40);
GrayF64 tranI = new GrayF64(30, 40);
GrayF64 output = new GrayF64(30, 40);
ImageMiscOps.fillUniform(input, rand, 0, 100);
FourierTransformNaive_F64.forward(input, tranR, tranI);
FourierTransformNaive_F64.inverse(tranR, tranI, output);
BoofTesting.assertEquals(input, output, 1e-7);
}
use of boofcv.struct.image.GrayF64 in project BoofCV by lessthanoptimal.
the class TestCirculantTracker method computeCosineWindow.
@Test
public void computeCosineWindow() {
GrayF64 found = new GrayF64(20, 25);
CirculantTracker.computeCosineWindow(found);
// should be between 0 and 1
for (int i = 0; i < found.data.length; i++) {
assertTrue(found.data[i] >= 0 && found.data[i] <= 1);
}
centeredSymmetricChecks(found, false);
}
use of boofcv.struct.image.GrayF64 in project BoofCV by lessthanoptimal.
the class TestCirculantTracker method imageDotProduct.
@Test
public void imageDotProduct() {
GrayF64 a = new GrayF64(width, height);
ImageMiscOps.fillUniform(a, rand, 0, 10);
double total = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
total += a.get(x, y) * a.get(x, y);
}
}
double found = CirculantTracker.imageDotProduct(a);
assertEquals(total, found, 1e-8);
}
use of boofcv.struct.image.GrayF64 in project BoofCV by lessthanoptimal.
the class TestCirculantTracker method performLearning.
@Test
public void performLearning() {
float interp_factor = 0.075f;
GrayF32 a = new GrayF32(20, 25);
GrayF32 b = new GrayF32(20, 25);
ImageMiscOps.fill(a, 100);
ImageMiscOps.fill(b, 200);
CirculantTracker<GrayF32> alg = new CirculantTracker<>(1f / 16, 0.2, 1e-2, 0.075, 1.0, 64, 255, interp);
alg.initialize(a, 0, 0, 20, 25);
// copy its internal value
GrayF64 templateC = new GrayF64(alg.template.width, alg.template.height);
templateC.setTo(alg.template);
// give it two images
alg.performLearning(b);
// make sure the images aren't full of zero
assertTrue(Math.abs(ImageStatistics.sum(templateC)) > 0.1);
assertTrue(Math.abs(ImageStatistics.sum(alg.template)) > 0.1);
int numNotSame = 0;
// the result should be an average of the two
for (int i = 0; i < a.data.length; i++) {
if (Math.abs(a.data[i] - alg.templateNew.data[i]) > 1e-4)
numNotSame++;
// should be more like the original one than the new one
double expected = templateC.data[i] * (1 - interp_factor) + interp_factor * alg.templateNew.data[i];
double found = alg.template.data[i];
assertEquals(expected, found, 1e-4);
}
// make sure it is actually different
assertTrue(numNotSame > 100);
}
Aggregations