本文整理汇总了C#中Bgr.ToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Bgr.ToBitmap方法的具体用法?C# Bgr.ToBitmap怎么用?C# Bgr.ToBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bgr
的用法示例。
在下文中一共展示了Bgr.ToBitmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var img = new Bgr<byte>[480, 640];
//***********************************************************************************************************************************************************************
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("********* TColor[,] <=> Image<> conversions (built-in) ****************"); Console.ResetColor();
//to Image<>
Image<Bgr<byte>> lockedImg = img.Lock();
//from Image<>
var arr = lockedImg.Clone();
//***********************************************************************************************************************************************************************
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("********* Image<,> <=> OpenCV conversions (built-in) ****************"); Console.ResetColor();
//to IplImage
IplImage iplImage;
using (var uImg = img.Lock())
{
iplImage = uImg.AsOpenCvImage(); //data is shared
}
//from IplImage
var imgFromIpl = iplImage.AsImage();
//***********************************************************************************************************************************************************************
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("*********** Image<,> <=> Bitmap conversions (BitmapInterop) ****************"); Console.ResetColor();
//to Bitmap
var bmp = img.ToBitmap();
//from Bitmap
var imgFromBmp = bmp.ToArray();
}
示例2: FormGroupMatch
public FormGroupMatch()
{
InitializeComponent();
debugImage = new Bgr<byte>[pictureBox.Height, pictureBox.Width];
var detections = getDetections();
drawDetections(detections, Bgr<byte>.Red, 1);
groupMatching = new RectangleClustering();
var clusters = groupMatching.Group(detections);
drawDetections(clusters.Select(x => x.Representative), Bgr<byte>.Green, 3);
pictureBox.Image = debugImage.ToBitmap();
}
示例3: Main
static void Main(string[] args)
{
var img = new Bgr<byte>[480, 640];
//***********************************************************************************************************************************************************************
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("********* TColor[,] <=> Image<> conversions (built-in) ****************"); Console.ResetColor();
//to Image<>
Image<Bgr<byte>> lockedImg = img.Lock();
//from Image<>
var arr = lockedImg.Clone();
//***********************************************************************************************************************************************************************
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("********* Image<,> <=> OpenCV conversions (built-in) ****************"); Console.ResetColor();
//to IplImage
IplImage iplImage;
using (var uImg = img.Lock())
{
iplImage = uImg.AsCvIplImage(); //data is shared
}
//from IplImage
var imgFromIpl = iplImage.AsImage();
//***********************************************************************************************************************************************************************
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("*********** Image<,> <=> Bitmap conversions (BitmapInterop) ****************"); Console.ResetColor();
//to Bitmap
var bmp = img.ToBitmap();
//from Bitmap
var imgFromBmp = bmp.ToArray();
//***********************************************************************************************************************************************************************
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("*********** Image<,> <=> BitmapSource conversions (BitmapSourceInterop) ****************"); Console.ResetColor();
//to generic-image
var colorBitmap = new BitmapImage(new Uri("http://www.online-image-editor.com//styles/2014/images/example_image.png"));
Bgra<byte>[,] colorImg = colorBitmap.ToArray<Bgra<byte>>();
//to BitmapSource
Gray<byte>[,] grayImg = img.ToGray();
BitmapSource grayBitmap = grayImg.ToBitmapSource();
}