Search in sources :

Example 6 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestImplDescribePointPixelRegionNCC_U8 method checkInner.

public void checkInner(GrayU8 image, int c_x, int c_y, int w, int h) {
    ImplDescribePointPixelRegionNCC_U8 alg = new ImplDescribePointPixelRegionNCC_U8(w, h);
    NccFeature desc = new NccFeature(alg.getDescriptorLength());
    alg.setImage(image);
    assertTrue(alg.isInBounds(c_x, c_y));
    alg.process(c_x, c_y, desc);
    int y0 = c_y - h / 2;
    int x0 = c_x - w / 2;
    double mean = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++) {
            mean += image.get(x, y);
        }
    }
    mean /= w * h;
    double variance = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++) {
            double a = image.get(x, y) - mean;
            variance += a * a;
        }
    }
    variance /= w * h;
    assertEquals(desc.mean, mean, 1e-8);
    assertEquals(desc.sigma, Math.sqrt(variance), 1e-8);
    int index = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++, index++) {
            assertEquals(image.get(x, y) - mean, desc.value[index], 1e-4);
        }
    }
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Example 7 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestConvertDescriptors method convertNcc_F64.

@Test
public void convertNcc_F64() {
    TupleDesc_F64 desc = new TupleDesc_F64(100);
    for (int i = 0; i < desc.size(); i++) {
        desc.value[i] = rand.nextDouble() * 2 - 1;
    }
    NccFeature found = new NccFeature(100);
    ConvertDescriptors.convertNcc(desc, found);
    for (int i = 0; i < desc.size(); i++) {
        assertEquals(desc.value[i], found.value[i] + found.mean, 1e-8);
    }
    // crude test.  just makes sure signa has been set really.
    assertTrue(found.sigma > 0);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Example 8 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestImplDescribePointPixelRegionNCC_F32 method checkInner.

public void checkInner(GrayF32 image, int c_x, int c_y, int w, int h) {
    ImplDescribePointPixelRegionNCC_F32 alg = new ImplDescribePointPixelRegionNCC_F32(w, h);
    NccFeature desc = new NccFeature(alg.getDescriptorLength());
    alg.setImage(image);
    assertTrue(alg.isInBounds(c_x, c_y));
    alg.process(c_x, c_y, desc);
    int y0 = c_y - h / 2;
    int x0 = c_x - w / 2;
    double mean = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++) {
            mean += image.get(x, y);
        }
    }
    mean /= w * h;
    double variance = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++) {
            double a = image.get(x, y) - mean;
            variance += a * a;
        }
    }
    variance /= w * h;
    assertEquals(desc.mean, mean, 1e-8);
    assertEquals(desc.sigma, Math.sqrt(variance), 1e-8);
    int index = 0;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++, index++) {
            assertEquals(image.get(x, y) - mean, desc.value[index], 1e-4);
        }
    }
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Example 9 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestImplDescribePointPixelRegionNCC_U8 method checkBorder.

public void checkBorder(GrayU8 image, int c_x, int c_y, int w, int h) {
    ImplDescribePointPixelRegionNCC_U8 alg = new ImplDescribePointPixelRegionNCC_U8(w, h);
    NccFeature desc = new NccFeature(alg.getDescriptorLength());
    alg.setImage(image);
    assertFalse(alg.isInBounds(c_x, c_y));
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Example 10 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestScoreAssociateNccFeature method compareToExpected.

@Test
public void compareToExpected() {
    ScoreAssociateNccFeature scorer = new ScoreAssociateNccFeature();
    NccFeature a = new NccFeature(5);
    NccFeature b = new NccFeature(5);
    a.sigma = 12;
    b.sigma = 7;
    a.value = new double[] { 1, 2, 3, 4, 5 };
    b.value = new double[] { 2, -1, 7, -8, 10 };
    assertEquals(-0.46429 / 5.0, scorer.score(a, b), 1e-2);
}
Also used : NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Aggregations

NccFeature (boofcv.struct.feature.NccFeature)13 Test (org.junit.Test)5 DescribePointPixelRegionNCC (boofcv.alg.feature.describe.DescribePointPixelRegionNCC)1 TldRegion (boofcv.alg.tracker.tld.TldRegion)1 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1