Search in sources :

Example 6 with Complex_F64

use of org.ejml.data.Complex_F64 in project BoofCV by lessthanoptimal.

the class TestDiscreteFourierTransformOps method multiplyComplex.

public void multiplyComplex(ImageInterleaved complexA, ImageInterleaved complexB, ImageInterleaved complexC) {
    if (complexB instanceof InterleavedF32)
        DiscreteFourierTransformOps.multiplyComplex((InterleavedF32) complexA, (InterleavedF32) complexB, (InterleavedF32) complexC);
    else
        DiscreteFourierTransformOps.multiplyComplex((InterleavedF64) complexA, (InterleavedF64) complexB, (InterleavedF64) complexC);
    Complex_F64 expected = new Complex_F64();
    for (int y = 0; y < complexA.height; y++) {
        for (int x = 0; x < complexA.width; x++) {
            Complex_F64 a = new Complex_F64(get(complexA, x, y, 0), get(complexA, x, y, 1));
            Complex_F64 b = new Complex_F64(get(complexB, x, y, 0), get(complexB, x, y, 1));
            ComplexMath_F64.multiply(a, b, expected);
            assertEquals(expected.getReal(), get(complexC, x, y, 0), 1e-4);
            assertEquals(expected.getImaginary(), get(complexC, x, y, 1), 1e-4);
        }
    }
}
Also used : Complex_F64(org.ejml.data.Complex_F64)

Example 7 with Complex_F64

use of org.ejml.data.Complex_F64 in project BoofCV by lessthanoptimal.

the class TestCirculantTracker method computeAlphas.

@Test
public void computeAlphas() {
    InterleavedF64 yf = new InterleavedF64(width, height, 2);
    InterleavedF64 kf = new InterleavedF64(width, height, 2);
    InterleavedF64 alphaf = new InterleavedF64(width, height, 2);
    ImageMiscOps.fillUniform(yf, rand, -10, 10);
    ImageMiscOps.fillUniform(kf, rand, -10, 10);
    ImageMiscOps.fillUniform(alphaf, rand, -10, 10);
    float lambda = 0.01f;
    CirculantTracker.computeAlphas(yf, kf, lambda, alphaf);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            Complex_F64 a = new Complex_F64(yf.getBand(x, y, 0), yf.getBand(x, y, 1));
            Complex_F64 b = new Complex_F64(kf.getBand(x, y, 0) + lambda, kf.getBand(x, y, 1));
            Complex_F64 c = new Complex_F64();
            ComplexMath_F64.divide(a, b, c);
            double foundReal = alphaf.getBand(x, y, 0);
            double foundImg = alphaf.getBand(x, y, 1);
            assertEquals(c.real, foundReal, 1e-4);
            assertEquals(c.imaginary, foundImg, 1e-4);
        }
    }
}
Also used : Complex_F64(org.ejml.data.Complex_F64) InterleavedF64(boofcv.struct.image.InterleavedF64) Test(org.junit.Test)

Example 8 with Complex_F64

use of org.ejml.data.Complex_F64 in project BoofCV by lessthanoptimal.

the class EssentialNister5 method process.

/**
 * Computes the essential matrix from point correspondences.
 *
 * @param points Input: List of points correspondences in normalized image coordinates
 * @param solutions Output: Storage for the found solutions.   .
 * @return true for success or false if a fault has been detected
 */
public boolean process(List<AssociatedPair> points, FastQueue<DMatrixRMaj> solutions) {
    if (points.size() != 5)
        throw new IllegalArgumentException("Exactly 5 points are required, not " + points.size());
    solutions.reset();
    // Computes the 4-vector span which contains E.  See equations 7-9
    computeSpan(points);
    // Construct a linear system based on the 10 constraint equations. See equations 5,6, and 10 .
    helper.setNullSpace(X, Y, Z, W);
    helper.setupA1(A1);
    helper.setupA2(A2);
    // instead of Gauss-Jordan elimination LU decomposition is used to solve the system
    solver.setA(A1);
    solver.solve(A2, C);
    // construct the z-polynomial matrix.  Equations 11-14
    helper.setDeterminantVectors(C);
    helper.extractPolynomial(poly.getCoefficients());
    if (!findRoots.process(poly))
        return false;
    for (Complex_F64 c : findRoots.getRoots()) {
        if (!c.isReal())
            continue;
        solveForXandY(c.real);
        DMatrixRMaj E = solutions.grow();
        for (int i = 0; i < 9; i++) {
            E.data[i] = x * X[i] + y * Y[i] + z * Z[i] + W[i];
        }
    }
    return true;
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) Complex_F64(org.ejml.data.Complex_F64)

Aggregations

Complex_F64 (org.ejml.data.Complex_F64)8 InterleavedF64 (boofcv.struct.image.InterleavedF64)2 DMatrixRMaj (org.ejml.data.DMatrixRMaj)2 Test (org.junit.Test)2