public Vector <float> CalculateVelocityAreaLS(UnmanagedImage current, UnmanagedImage previous, IntPoint point, int n, int winSize, float sigma) { Matrix <float> Br = CalculateBr(n); // I : [x - winSize; x + winSize] x [y - wS; y + wS] Func <float, float> _weight = (d) => (float)(Math.Exp(-d * d / (2 * sigma * sigma))); Matrix <float> wAtASum = new DenseMatrix(2, 2); Vector <float> wAtdeltabSum = new DenseVector(2); for (int dx = -winSize; dx <= winSize; dx++) { for (int dy = -winSize; dy <= winSize; dy++) { IntPoint p = new IntPoint(point.X + dx, point.Y + dy); float w = _weight(dx) * _weight(dy); PolyCoefficients pc1Val = PolynomialExpansion(current, n, p, Br); PolyCoefficients pc2Val = PolynomialExpansion(previous, n, p, Br); Matrix <float> A = pc1Val.A + pc2Val.A; //).Multiply(0.5f); Matrix <float> At = A.Transpose(); Vector <float> deltab = pc2Val.B - pc1Val.B; //).Multiply(0.5f); wAtASum.Add(A * At * w, wAtASum); wAtdeltabSum.Add(At * deltab * w, wAtdeltabSum); } } return(wAtASum.Inverse() * wAtdeltabSum); }
public Vector <float> CalculateVelocityPointwise(UnmanagedImage current, UnmanagedImage previous, IntPoint point, int n) { Matrix <float> Br = CalculateBr(n); PolyCoefficients pc1Val = PolynomialExpansion(current, n, point, Br); PolyCoefficients pc2Val = PolynomialExpansion(previous, n, point, Br); Matrix <float> A = pc1Val.A + pc2Val.A; Vector <float> deltab = pc2Val.B - pc1Val.B; return(A.Inverse() * deltab); }
public ModbusRegister() { registerBuf = new ushort[REGISTER_SIZE]; ApproxTable = new List <ApproxValues>(30); PolyCoeffs = new PolyCoefficients(); }