Search in sources :

Example 41 with TupleDesc_F64

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

the class DescribeDenseHogFastAlg method computeDescriptor.

/**
 * Compute the descriptor from the specified cells.  (row,col) to (row+w,col+w)
 * @param row Lower extent of cell rows
 * @param col Lower extent of cell columns
 */
void computeDescriptor(int row, int col) {
    // set location to top-left pixel
    locations.grow().set(col * pixelsPerCell, row * pixelsPerCell);
    TupleDesc_F64 d = descriptions.grow();
    int indexDesc = 0;
    for (int i = 0; i < cellsPerBlockY; i++) {
        for (int j = 0; j < cellsPerBlockX; j++) {
            Cell c = cells[(row + i) * cellCols + (col + j)];
            for (int k = 0; k < c.histogram.length; k++) {
                d.value[indexDesc++] = c.histogram[k];
            }
        }
    }
    // Apply SIFT style L2-Hys normalization
    DescribeSiftCommon.normalizeDescriptor(d, 0.2);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64)

Example 42 with TupleDesc_F64

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

the class StandardTupleDescribeTests method checkSubImage.

/**
 * Does it produce a the same features when given a subimage?
 */
@Test
public void checkSubImage() {
    TupleDesc_F64 expected = describe(c_x, c_y, 0, image);
    GrayF32 sub = BoofTesting.createSubImageOf(image);
    TupleDesc_F64 found = describe(c_x, c_y, 0, sub);
    BoofTesting.assertEquals(expected.value, found.value, 1e-8);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 43 with TupleDesc_F64

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

the class StandardTupleDescribeTests method changeRotation.

/**
 * Does it produce a different feature when rotated?
 */
@Test
public void changeRotation() {
    TupleDesc_F64 a = describe(c_x, c_y, 0, image);
    TupleDesc_F64 b = describe(c_x, c_y, 1, image);
    boolean equals = true;
    for (int i = 0; i < a.value.length; i++) {
        double diff = Math.abs(a.value[i] - b.value[i]);
        if (diff > 1e-8) {
            equals = false;
            break;
        }
    }
    assertFalse(equals);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 44 with TupleDesc_F64

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

the class TestDescribePointSift method computeRawDescriptor_scale.

/**
 * Only put gradient inside a small area that fills the descriptor.  Then double the scale and see if
 * only a 1/4 of the original image is inside
 */
@Test
public void computeRawDescriptor_scale() {
    GrayF32 derivX = new GrayF32(200, 200);
    GrayF32 derivY = new GrayF32(200, 200);
    DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
    int r = alg.getCanonicalRadius();
    ImageMiscOps.fillRectangle(derivX, 5.0f, 60, 60, 2 * r, 2 * r);
    alg.setImageGradient(derivX, derivY);
    alg.descriptor = new TupleDesc_F64(128);
    alg.computeRawDescriptor(60 + r, 60 + r, 1, 0);
    int numHit = computeInside(alg);
    assertEquals(4 * 4, numHit);
    alg.descriptor = new TupleDesc_F64(128);
    alg.computeRawDescriptor(60 + r, 60 + r, 2, 0);
    numHit = computeInside(alg);
    // would be 2x2 if there was no interpolation
    assertEquals(3 * 3, numHit);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 45 with TupleDesc_F64

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

the class TestDescribePointSift method computeRawDescriptor_rotation.

/**
 * Have a constant gradient, which has an easy to understand descriptor, then rotate the feature and see
 * if the description changes as expected.
 */
@Test
public void computeRawDescriptor_rotation() {
    GrayF32 derivX = new GrayF32(60, 55);
    GrayF32 derivY = new GrayF32(60, 55);
    ImageMiscOps.fill(derivX, 5.0f);
    DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
    alg.setImageGradient(derivX, derivY);
    for (int i = 0; i < 8; i++) {
        double angle = UtilAngle.bound(i * Math.PI / 4);
        alg.descriptor = new TupleDesc_F64(128);
        alg.computeRawDescriptor(20, 21, 1, angle);
        int bin = (int) (UtilAngle.domain2PI(-angle) * 8 / (2 * Math.PI));
        for (int j = 0; j < 128; j++) {
            if (j % 8 == bin) {
                assertTrue(alg.descriptor.value[j] > 0);
            } else {
                assertEquals(0, alg.descriptor.value[j], 1e-4);
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Aggregations

TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)66 Test (org.junit.Test)47 GrayF32 (boofcv.struct.image.GrayF32)17 GrayU8 (boofcv.struct.image.GrayU8)8 Point2D_I32 (georegression.struct.point.Point2D_I32)6 TupleDesc_S8 (boofcv.struct.feature.TupleDesc_S8)5 ArrayList (java.util.ArrayList)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)4 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)3 TupleDesc_U8 (boofcv.struct.feature.TupleDesc_U8)3 Planar (boofcv.struct.image.Planar)3 Point3D_F64 (georegression.struct.point.Point3D_F64)3 HistogramScene (boofcv.alg.scene.HistogramScene)2 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)2 ImageGray (boofcv.struct.image.ImageGray)2 IOException (java.io.IOException)2 FastQueue (org.ddogleg.struct.FastQueue)2