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


C# Matrix.GetSubRect方法代码示例

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


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

示例1: TestConcate

        public void TestConcate()
        {
            Matrix<float> mat = new Matrix<float>(30, 40);
             mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));

             Matrix<float> m1 = mat.GetSubRect(new Rectangle(0, 0, mat.Cols, 20));
             Matrix<float> m2 = mat.GetSubRect(new Rectangle(0, 20, mat.Cols, mat.Rows - 20));
             Matrix<float> mat2 = m1.ConcateVertical(m2);
             Assert.IsTrue(mat.Equals(mat2));

             Matrix<float> m3 = mat.GetSubRect(new Rectangle(0, 0, 10, mat.Rows));
             Matrix<float> m4 = mat.GetSubRect(new Rectangle(10, 0, mat.Cols - 10, mat.Rows));
             Matrix<float> mat3 = m3.ConcateHorizontal(m4);
             Assert.IsTrue(mat.Equals(mat3));

             Matrix<float> m5 = mat.GetRows(0, 5, 1);
             Matrix<float> m6 = mat.GetRows(5, 6, 1);
             Matrix<float> m7 = mat.GetRows(6, mat.Rows, 1);
             Assert.IsTrue(mat.RemoveRows(5, 6).Equals(m5.ConcateVertical(m7)));
             Assert.IsTrue(mat.RemoveRows(0, 1).Equals(mat.GetRows(1, mat.Rows, 1)));
             Assert.IsTrue(mat.RemoveRows(mat.Rows - 1, mat.Rows).Equals(mat.GetRows(0, mat.Rows - 1, 1)));
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:22,代码来源:AutoTestMatrix.cs

示例2: TestSubMatrix

      public void TestSubMatrix()
      {
         Matrix<float> mat = new Matrix<float>(30, 40);
         mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));
         Matrix<float> submat = mat.GetSubRect(new Rectangle(5, 5, 15, 15));
         for (int i = 0; i < 15; i++)
            for (int j = 0; j < 15; j++)
               EmguAssert.AreEqual(mat[i + 5, j + 5], submat[i, j]);

         Matrix<float> secondRow = mat.GetRow(1);
         for (int i = 0; i < mat.Cols; i++)
         {
            EmguAssert.AreEqual(mat[1, i], secondRow[0, i]);
         }

         Matrix<float> thirdCol = mat.GetCol(2);
         for (int i = 0; i < mat.Rows; i++)
         {
            EmguAssert.AreEqual(mat[i, 2], thirdCol[i, 0]);
         }

         Matrix<float> diagonal = mat.GetDiag();
         for (int i = 0; i < Math.Min(mat.Rows, mat.Cols); i++)
         {
            EmguAssert.AreEqual(diagonal[i, 0], mat[i, i]);
         }
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:27,代码来源:AutoTestMatrix.cs

示例3: TestImageDFT

      public void TestImageDFT()
      {
         Image<Gray, float> matA = EmguAssert.LoadImage<Gray, float>("stuff.jpg");

         //The matrix to be convolved with matA, a bluring filter
         Matrix<float> matB = new Matrix<float>(
            new float[,] { 
            {1.0f / 16.0f, 1.0f / 16.0f, 1.0f / 16.0f}, 
            {1.0f / 16.0f, 8.0f / 16.0f, 1.0f / 16.0f}, 
            {1.0f / 16.0f, 1.0f / 16.0f, 1.0f / 16.0f}});

         Image<Gray, float> convolvedImage = new Image<Gray, float>(new Size(matA.Width + matB.Width -1, matA.Height + matB.Height -1));

         Matrix<float> dftA = new Matrix<float>(
            CvInvoke.GetOptimalDFTSize(convolvedImage.Rows),
            CvInvoke.GetOptimalDFTSize(convolvedImage.Cols));
         matA.CopyTo(dftA.GetSubRect(matA.ROI));

         CvInvoke.Dft(dftA, dftA, Emgu.CV.CvEnum.DxtType.Forward, matA.Rows);

         Matrix<float> dftB = new Matrix<float>(dftA.Size);
         matB.CopyTo(dftB.GetSubRect(new Rectangle(Point.Empty, matB.Size)));
         CvInvoke.Dft(dftB, dftB, Emgu.CV.CvEnum.DxtType.Forward, matB.Rows);

         CvInvoke.MulSpectrums(dftA, dftB, dftA, Emgu.CV.CvEnum.MulSpectrumsType.Default, false);
         CvInvoke.Dft(dftA, dftA, Emgu.CV.CvEnum.DxtType.Inverse, convolvedImage.Rows);
         dftA.GetSubRect(new Rectangle(Point.Empty, convolvedImage.Size)).CopyTo(convolvedImage);
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:28,代码来源:AutoTestImage.cs

示例4: TestImageDFT

        public void TestImageDFT()
        {
            Image<Gray, float> matA = new Image<Gray, float>("stuff.jpg");

             //The matrix to be convoled with matA, a bluring filter
             Matrix<float> matB = new Matrix<float>(
            new float[,] {
            {1.0f/16.0f, 1.0f/16.0f, 1.0f/16.0f},
            {1.0f/16.0f, 8.0f/16.0f, 1.0f/16.0f},
            {1.0f/16.0f, 1.0f/16.0f, 1.0f/16.0f}});

             Image<Gray, float> convolvedImage = new Image<Gray, float>(matA.Size + matB.Size - new Size(1, 1));

             Matrix<float> dftA = new Matrix<float>(
            CvInvoke.cvGetOptimalDFTSize(convolvedImage.Rows),
            CvInvoke.cvGetOptimalDFTSize(convolvedImage.Cols));
             matA.CopyTo(dftA.GetSubRect(matA.ROI));

             CvInvoke.cvDFT(dftA, dftA, Emgu.CV.CvEnum.CV_DXT.CV_DXT_FORWARD, matA.Rows);

             Matrix<float> dftB = new Matrix<float>(dftA.Size);
             matB.CopyTo(dftB.GetSubRect(new Rectangle(Point.Empty, matB.Size)));
             CvInvoke.cvDFT(dftB, dftB, Emgu.CV.CvEnum.CV_DXT.CV_DXT_FORWARD, matB.Rows);

             CvInvoke.cvMulSpectrums(dftA, dftB, dftA, Emgu.CV.CvEnum.MUL_SPECTRUMS_TYPE.DEFAULT);
             CvInvoke.cvDFT(dftA, dftA, Emgu.CV.CvEnum.CV_DXT.CV_DXT_INVERSE, convolvedImage.Rows);
             dftA.GetSubRect(new Rectangle(Point.Empty, convolvedImage.Size)).CopyTo(convolvedImage);
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:28,代码来源:AutoTestImage.cs


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