本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.PointwiseAddThis方法的典型用法代码示例。如果您正苦于以下问题:C# DenseMatrix.PointwiseAddThis方法的具体用法?C# DenseMatrix.PointwiseAddThis怎么用?C# DenseMatrix.PointwiseAddThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.PointwiseAddThis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMatrix
public Matrix<double> GetMatrix()
{
Matrix<double> mat = new DenseMatrix(RowCount, ColumnCount);
for(int ch = 0; ch < ChannelsCount; ++ch)
{
mat.PointwiseAddThis(ImageMatrix[ch]);
}
mat.MultiplyThis(1.0 / 3.0);
return mat;
}
示例2: Match
public override void Match()
{
int r21 = 2 * WindowRadius + 1;
_leftMoments = new List<Vector<double>>();
_rightMoments = new List<Vector<double>>();
// Find circural mask bounds:
// for x = [-r,r] -> y = [ -sqrt(r^2 - x^2), sqrt(r^2 - x^2) ]
_ybounds = new int[r21];
for(int x = -WindowRadius; x <= WindowRadius; ++x)
{
_ybounds[x + WindowRadius] = (int)Math.Sqrt(WindowRadius * WindowRadius - x * x);
}
// Find moment vectors for each feature point
for(int i = 0; i < LeftFeaturePoints.Count; ++i)
{
IntVector2 pixel = LeftFeaturePoints[i];
if(pixel.X < WindowRadius || pixel.Y < WindowRadius ||
pixel.X >= LeftImage.ColumnCount - WindowRadius ||
pixel.Y >= LeftImage.RowCount - WindowRadius)
{
_leftMoments.Add(null);
}
else
{
Vector<double> mom = ComputeMomentVectorForPatch(pixel, LeftImage);
if(UseCenteredMoments)
mom = ComputeCenteredMomentVector(mom);
if(UseScaledMoments)
ScaleMomentVector(mom);
Vector<double> invMom = ComputeInvariantMomentVector(mom);
_leftMoments.Add(invMom);
}
}
for(int i = 0; i < RightFeaturePoints.Count; ++i)
{
IntVector2 pixel = RightFeaturePoints[i];
if(pixel.X < WindowRadius || pixel.Y < WindowRadius ||
pixel.X >= RightImage.ColumnCount - WindowRadius ||
pixel.Y >= RightImage.RowCount - WindowRadius)
{
_rightMoments.Add(null);
}
else
{
Vector<double> mom = ComputeMomentVectorForPatch(pixel, RightImage);
if(UseCenteredMoments)
mom = ComputeCenteredMomentVector(mom);
if(UseScaledMoments)
ScaleMomentVector(mom);
Vector<double> invMom = ComputeInvariantMomentVector(mom);
_rightMoments.Add(invMom);
}
}
// We need to find covariance matrix of invariants as they have
// different magnitudes, so simple ||Il - Ir|| may not be best choice
// E = 1/(n-1) sum( (xi-m)(xi-m)^T ) (x is column vector, m = 1/n sum(xi)
// 1) Find mean
int n = 0;
Vector<double> meanInv = new DenseVector(_invCount);
for(int i = 0; i < _leftMoments.Count; ++i)
{
if(_leftMoments[i] != null)
{
meanInv.PointwiseAddThis(_leftMoments[i]);
++n;
}
}
for(int i = 0; i < _rightMoments.Count; ++i)
{
if(_rightMoments[i] != null)
{
meanInv.PointwiseAddThis(_rightMoments[i]);
++n;
}
}
meanInv.MultiplyThis(1.0 / n);
// 2) Find E
Matrix<double> cov = new DenseMatrix(_invCount, _invCount);
for(int i = 0; i < _leftMoments.Count; ++i)
{
if(_leftMoments[i] != null)
{
cov.PointwiseAddThis(CamCore.MatrixExtensions.FromVectorProduct(_leftMoments[i] - meanInv));
}
}
for(int i = 0; i < _rightMoments.Count; ++i)
{
if(_rightMoments[i] != null)
{
cov.PointwiseAddThis(CamCore.MatrixExtensions.FromVectorProduct(_rightMoments[i] - meanInv));
}
}
cov.MultiplyThis(1.0 / (n - 1));
var covInv = cov.Inverse();
// Match each point pair and find ||Il - Ir||E
//.........这里部分代码省略.........