本文整理汇总了C#中Image.SetRandNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Image.SetRandNormal方法的具体用法?C# Image.SetRandNormal怎么用?C# Image.SetRandNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.SetRandNormal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBGModel
public void TestBGModel()
{
int width = 300;
int height = 400;
Image<Bgr, Byte> bg = new Image<Bgr, byte>(width, height);
bg.SetRandNormal(new MCvScalar(), new MCvScalar(100, 100, 100));
Size size = new Size(width / 10, height / 10);
Point topLeft = new Point((width >> 1) - (size.Width >> 1), (height >> 1) - (size.Height >> 1));
Rectangle rect = new Rectangle(topLeft, size);
Image<Bgr, Byte> img1 = bg.Copy();
img1.Draw(rect, new Bgr(Color.Red), -1);
Image<Bgr, Byte> img2 = bg.Copy();
rect.Offset(10, 0);
img2.Draw(rect, new Bgr(Color.Red), -1);
BGStatModel<Bgr> model1 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.GAUSSIAN_BG_MODEL);
model1.Update(img2);
BGStatModel<Bgr> model2 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.FGD_STAT_MODEL);
model2.Update(img2);
//ImageViewer.Show(model2.Foreground);
//ImageViewer.Show(model1.Background);
}
示例2: TestModuleInfo
/*
public void TestModuleInfo()
{
string pluginName;
string versionName;
CvToolbox.GetModuleInfo(out pluginName, out versionName);
Trace.WriteLine(String.Format("Plugin: {0}\r\nVersion: {1}", pluginName, versionName ));
}*/
public void TestRandom()
{
using (Image<Bgr, byte> img = new Image<Bgr, byte>(200, 200))
{
img.SetRandNormal(new MCvScalar(0.0, 0.0, 0.0), new MCvScalar(50.0, 50.0, 50.0));
ImageViewer.Show(img);
}
}
示例3: TestFlipPerformance
public void TestFlipPerformance()
{
Image<Bgr, byte> image = new Image<Bgr, byte>(2048, 1024);
image.SetRandNormal(new MCvScalar(), new MCvScalar(255, 255, 255));
Stopwatch watch = Stopwatch.StartNew();
image._Flip(Emgu.CV.CvEnum.FlipType.Horizontal | Emgu.CV.CvEnum.FlipType.Vertical);
watch.Stop();
EmguAssert.WriteLine(String.Format("Time used: {0} milliseconds", watch.ElapsedMilliseconds));
}
示例4: TestBitmapConversion
public void TestBitmapConversion()
{
Stopwatch watch = Stopwatch.StartNew();
Image<Bgr, Byte> image0 = new Image<Bgr, byte>(1200, 1080);
image0.SetRandNormal(new MCvScalar(120, 120, 120), new MCvScalar(50, 50, 50) );
WriteableBitmap bmp = image0.Mat.ToWritableBitmap();
Image<Bgr, Byte> image1 = WritableBitmapToImage(bmp);
watch.Stop();
Assert.IsTrue(image0.Equals(image1));
}
示例5: TestRotationSpeed
public void TestRotationSpeed()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(1024, 720);
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
Stopwatch watch = Stopwatch.StartNew();
Image<Bgr, Byte> imgRotated = img.Rotate(90, new Bgr(), false);
watch.Stop();
Trace.WriteLine(String.Format("Rotation time (wrap affine): {0}", watch.ElapsedMilliseconds));
EmguAssert.AreEqual(img.Width, imgRotated.Height);
EmguAssert.AreEqual(img.Height, imgRotated.Width);
watch.Reset();
watch.Start();
Image<Bgr, Byte> imgRotated2 = new Image<Bgr, byte>(img.Height, img.Width);
CvInvoke.Transpose(img, imgRotated2);
CvInvoke.Flip(imgRotated2, imgRotated2, FlipType.Horizontal);
watch.Stop();
Trace.WriteLine(String.Format("Rotation time (transpose & flip): {0}", watch.ElapsedMilliseconds));
EmguAssert.IsTrue(imgRotated.Equals(imgRotated2));
}
示例6: TestRotation
public void TestRotation()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(100, 80);
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
Image<Bgr, Byte> imgRotated = img.Rotate(90, new Bgr(), false);
EmguAssert.AreEqual(img.Width, imgRotated.Height);
EmguAssert.AreEqual(img.Height, imgRotated.Width);
imgRotated = img.Rotate(30, new Bgr(255, 255, 255), false);
//ImageViewer.Show(imgRotated);
}
示例7: TestXmlSerialize
public void TestXmlSerialize()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(100, 80);
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
img.SerializationCompressionRatio = 9;
XDocument doc1 = Toolbox.XmlSerialize<Image<Bgr, Byte>>(img);
String str = doc1.ToString();
Image<Bgr, Byte> img2 = Toolbox.XmlDeserialize<Image<Bgr, Byte>>(doc1);
EmguAssert.IsTrue(img.Equals(img2));
img.SerializationCompressionRatio = 9;
XDocument doc2 = Toolbox.XmlSerialize<Image<Bgr, Byte>>(img);
Image<Bgr, Byte> img3 = Toolbox.XmlDeserialize<Image<Bgr, Byte>>(doc2);
EmguAssert.IsTrue(img.Equals(img3));
XDocument doc3 = XDocument.Parse(str);
Image<Bgr, Byte> img4 = Toolbox.XmlDeserialize<Image<Bgr, Byte>>(doc3);
EmguAssert.IsTrue(img.Equals(img4));
}
示例8: TestCudaRemap
public void TestCudaRemap()
{
if (!CudaInvoke.HasCuda)
return;
Image<Gray, float> xmap = new Image<Gray, float>(2, 2);
xmap.Data[0, 0, 0] = 0; xmap.Data[0, 1, 0] = 0;
xmap.Data[1, 0, 0] = 1; xmap.Data[1, 1, 0] = 1;
Image<Gray, float> ymap = new Image<Gray, float>(2, 2);
ymap.Data[0, 0, 0] = 0; ymap.Data[0, 1, 0] = 1;
ymap.Data[1, 0, 0] = 0; ymap.Data[1, 1, 0] = 1;
Image<Gray, Byte> image = new Image<Gray, byte>(2, 2);
image.SetRandNormal(new MCvScalar(), new MCvScalar(255));
using (CudaImage<Gray, Byte> CudaImage = new CudaImage<Gray, byte>(image))
using (CudaImage<Gray, float> xCudaImage = new CudaImage<Gray, float>(xmap))
using (CudaImage<Gray, float> yCudaImage = new CudaImage<Gray, float>(ymap))
using (CudaImage<Gray, Byte> remapedImage = new CudaImage<Gray,byte>(CudaImage.Size))
{
CudaInvoke.Remap(CudaImage, remapedImage, xCudaImage, yCudaImage, CvEnum.Inter.Cubic, CvEnum.BorderType.Default, new MCvScalar(), null);
}
}
示例9: TestAvgSdv
public void TestAvgSdv()
{
Image<Gray, Single> img1 = new Image<Gray, float>(50, 20);
img1.SetRandNormal(new MCvScalar(100), new MCvScalar(30));
Gray mean;
MCvScalar std;
img1.AvgSdv(out mean, out std);
}
示例10: TestMultiThreadWithBMP
public void TestMultiThreadWithBMP()
{
//TODO: find out why this test fails on unix
if (Emgu.Util.Platform.OperationSystem == Emgu.Util.TypeEnum.OS.Windows)
{
int threadCount = 32;
//Create some random images and save to hard disk
String[] imageNames = new String[threadCount];
for (int i = 0; i < threadCount; i++)
{
using (Image<Bgr, Byte> img = new Image<Bgr, byte>(2048, 1024))
{
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
imageNames[i] = String.Format("tmp{0}.bmp", i);
img.Save(imageNames[i]);
}
}
Thread[] threads = new Thread[threadCount];
for (int i = 0; i < threadCount; i++)
{
int index = i;
threads[i] = new Thread(delegate()
{
{
Image<Gray, Byte> img = new Image<Gray, byte>(imageNames[index]);
Image<Gray, Byte> bmpClone = new Image<Gray, byte>(img.Bitmap);
}
});
threads[i].Priority = ThreadPriority.Highest;
threads[i].Start();
}
for (int i = 0; i < threadCount; i++)
{
threads[i].Join();
}
//delete random images;
foreach (string s in imageNames)
File.Delete(s);
}
}
示例11: TestMultiThreadInMemoryWithBMP
public void TestMultiThreadInMemoryWithBMP()
{
if (Emgu.Util.Platform.OperationSystem == Emgu.Util.TypeEnum.OS.Windows)
{
int threadCount = 32;
//Create some random images and save to hard disk
Bitmap[] imageNames = new Bitmap[threadCount];
for (int i = 0; i < threadCount; i++)
{
using (Image<Bgr, Byte> img = new Image<Bgr, byte>(2048, 1024))
{
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
imageNames[i] = img.ToBitmap();
}
}
Thread[] threads = new Thread[threadCount];
for (int i = 0; i < threadCount; i++)
{
int index = i;
threads[i] = new Thread(delegate()
{
Image<Gray, Byte> img = new Image<Gray, byte>(imageNames[index]);
Image<Gray, Byte> bmpClone = new Image<Gray, byte>(img.Bitmap);
});
threads[i].Priority = ThreadPriority.Highest;
threads[i].Start();
}
for (int i = 0; i < threadCount; i++)
{
threads[i].Join();
}
}
}
示例12: TestSetRandomNormal
public void TestSetRandomNormal()
{
Image<Bgr, Byte> image = new Image<Bgr, byte>(400, 200);
//image.SetRandUniform(new MCvScalar(), new MCvScalar(255, 255, 255));
image.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(20, 20, 20));
}
示例13: TestGamma
public void TestGamma()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(320, 240);
img.SetRandNormal(new MCvScalar(120, 120, 120), new MCvScalar(50, 50, 50));
img._GammaCorrect(0.5);
}
示例14: TestCudaWarpPerspective
public void TestCudaWarpPerspective()
{
if (!CudaInvoke.HasCuda)
return;
Matrix<float> transformation = new Matrix<float>(3, 3);
transformation.SetIdentity();
Image<Gray, byte> image = new Image<Gray, byte>(480, 320);
image.SetRandNormal(new MCvScalar(), new MCvScalar(255));
using (GpuMat cudaImage = new GpuMat(image))
using (CudaImage<Gray, Byte> resultCudaImage = new CudaImage<Gray, byte>())
{
CudaInvoke.WarpPerspective(cudaImage, resultCudaImage, transformation, cudaImage.Size, CvEnum.Inter.Cubic, CvEnum.BorderType.Default, new MCvScalar(), null);
}
}
示例15: TestRuntimeSerializeWithROI
public void TestRuntimeSerializeWithROI()
{
Image<Bgr, Byte> img = new Image<Bgr, byte>(100, 80);
using (MemoryStream ms = new MemoryStream())
{
img.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
img.SerializationCompressionRatio = 9;
img.ROI = new Rectangle(10, 10, 20, 30);
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(ms, img);
Byte[] bytes = ms.GetBuffer();
using (MemoryStream ms2 = new MemoryStream(bytes))
{
Object o = formatter.Deserialize(ms2);
Image<Bgr, Byte> img2 = (Image<Bgr, Byte>)o;
EmguAssert.IsTrue(img.Equals(img2));
}
}
}