本文整理汇总了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)));
}
示例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
}
示例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);
}
示例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]);
}
}
示例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
}
}
示例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]);
}
}
示例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]);
}
}
示例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));
}
}