当前位置: 首页>>代码示例>>C#>>正文


C# DenseVector.PointwiseAddThis方法代码示例

本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.DenseVector.PointwiseAddThis方法的典型用法代码示例。如果您正苦于以下问题:C# DenseVector.PointwiseAddThis方法的具体用法?C# DenseVector.PointwiseAddThis怎么用?C# DenseVector.PointwiseAddThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MathNet.Numerics.LinearAlgebra.Double.DenseVector的用法示例。


在下文中一共展示了DenseVector.PointwiseAddThis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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
//.........这里部分代码省略.........
开发者ID:KFlaga,项目名称:Cam3D,代码行数:101,代码来源:MomentsFeatureMatcher.cs


注:本文中的MathNet.Numerics.LinearAlgebra.Double.DenseVector.PointwiseAddThis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。