當前位置: 首頁>>代碼示例>>C#>>正文


C# Matrix.SetRandUniform方法代碼示例

本文整理匯總了C#中System.Matrix.SetRandUniform方法的典型用法代碼示例。如果您正苦於以下問題:C# Matrix.SetRandUniform方法的具體用法?C# Matrix.SetRandUniform怎麽用?C# Matrix.SetRandUniform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Matrix的用法示例。


在下文中一共展示了Matrix.SetRandUniform方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: TestMultiChannelMatrix

      public void TestMultiChannelMatrix()
      {
         Matrix<float> m = new Matrix<float>(10, 20, 2);
         m.SetRandUniform(new MCvScalar(), new MCvScalar(255, 255));
         EmguAssert.AreEqual(10, m.Rows);
         EmguAssert.AreEqual(20, m.Cols);
         EmguAssert.AreEqual(2, m.NumberOfChannels);

#if !WINDOWS_PHONE_APP
         XDocument xDoc = Toolbox.XmlSerialize<Matrix<float>>(m);
         Matrix<float> m2 = Toolbox.XmlDeserialize<Matrix<float>>(xDoc);
         EmguAssert.IsTrue(m.Equals(m2));
#endif
      }
開發者ID:neutmute,項目名稱:emgucv,代碼行數:14,代碼來源:AutoTestMatrix.cs

示例3: TestMinMax

 public void TestMinMax()
 {
    Matrix<float> mat = new Matrix<float>(30, 40);
    mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));
    double min, max;
    Point minLoc, maxLoc;
    mat.MinMax(out min, out max, out minLoc, out maxLoc, null);
 }
開發者ID:neutmute,項目名稱:emgucv,代碼行數:8,代碼來源:AutoTestMatrix.cs

示例4: 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

示例5: TestXmlSerializeAndDeserialize

      public void TestXmlSerializeAndDeserialize()
      {
         using (Matrix<Byte> mat = new Matrix<byte>(50, 60))
         {
            mat.SetRandUniform(new MCvScalar(0), new MCvScalar(255));

#if !WINDOWS_PHONE_APP
            XDocument doc = Toolbox.XmlSerialize<Matrix<Byte>>(mat);
            //Trace.WriteLine(doc.OuterXml);

            using (Matrix<Byte> mat2 = Toolbox.XmlDeserialize<Matrix<Byte>>(doc))
               EmguAssert.IsTrue(mat.Equals(mat2));
#endif
         }
      }
開發者ID:neutmute,項目名稱:emgucv,代碼行數:15,代碼來源:AutoTestMatrix.cs

示例6: TestTransposeFloatMatrix

      public void TestTransposeFloatMatrix()
      {
         using (Matrix<float> mat = new Matrix<float>(1, 3))
         {
            mat.SetRandUniform(new MCvScalar(-1000.0), new MCvScalar(1000.0));

            Matrix<float> matT = mat.Transpose();

            for (int i = 0; i < matT.Rows; i++)
               for (int j = 0; j < matT.Cols; j++)
                  EmguAssert.AreEqual(matT[i, j], mat[j, i]);
         }
      }
開發者ID:neutmute,項目名稱:emgucv,代碼行數:13,代碼來源:AutoTestMatrix.cs

示例7: TestTransposeByteMatrix

      public void TestTransposeByteMatrix()
      {
         using (Matrix<Byte> mat = new Matrix<Byte>(1, 10))
         {
            mat.SetRandUniform(new MCvScalar(0.0), new MCvScalar(255.0));

            Matrix<Byte> matT = mat.Transpose();

            for (int i = 0; i < matT.Rows; i++)
               for (int j = 0; j < matT.Cols; j++)
                  EmguAssert.AreEqual(matT[i, j], mat[j, i]);
         }
      }
開發者ID:neutmute,項目名稱:emgucv,代碼行數:13,代碼來源:AutoTestMatrix.cs

示例8: TestXmlSerializeAndDeserialize

        public void TestXmlSerializeAndDeserialize()
        {
            using (Matrix<Byte> mat = new Matrix<byte>(50, 60))
             {
            mat.SetRandUniform((ulong)DateTime.Now.Ticks, new MCvScalar(0), new MCvScalar(255));
            XmlDocument doc = Toolbox.XmlSerialize<Matrix<Byte>>(mat);
            //Trace.WriteLine(doc.OuterXml);

            using (Matrix<Byte> mat2 = Toolbox.XmlDeserialize<Matrix<Byte>>(doc))
               Assert.IsTrue(mat.Equals(mat2));

             }
        }
開發者ID:samuto,項目名稱:UnityOpenCV,代碼行數:13,代碼來源:AutoTestMatrix.cs


注:本文中的System.Matrix.SetRandUniform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。