本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.ToIplImage方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.ToIplImage方法的具体用法?C# WriteableBitmap.ToIplImage怎么用?C# WriteableBitmap.ToIplImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.ToIplImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestWriteableBitmap
/// <summary>
/// WriteableBitmap -> IplImage
/// </summary>
private void TestWriteableBitmap()
{
// Load 16-bit image to WriteableBitmap
PngBitmapDecoder decoder = new PngBitmapDecoder(
new Uri(FilePath.Image.Depth16Bit, UriKind.Relative),
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default
);
BitmapSource bs = decoder.Frames[0];
WriteableBitmap wb = new WriteableBitmap(bs);
// Convert wb into IplImage
IplImage ipl = wb.ToIplImage();
//IplImage ipl32 = new IplImage(wb.PixelWidth, wb.PixelHeight, BitDepth.U16, 1);
//WriteableBitmapConverter.ToIplImage(wb, ipl32);
// Print pixel values
for (int i = 0; i < ipl.Height; i++)
{
Console.WriteLine("x:{0} y:{1} v:{2}", i, i, ipl[i, 128]);
}
// Show 16-bit IplImage
using (new CvWindow("from WriteableBitmap to IplImage", ipl))
{
Cv.WaitKey();
}
}
示例2: TestWriteableBitmapBgr32
/// <summary>
/// WriteableBitmap (Format = Bgr32) -> IplImage
/// </summary>
private void TestWriteableBitmapBgr32()
{
// loads color image
PngBitmapDecoder decoder = new PngBitmapDecoder(
new Uri(FilePath.Image.Lenna, UriKind.Relative),
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default
);
BitmapSource bs = decoder.Frames[0];
// converts pixelformat from Bgr24 to Bgr32 (for this test)
FormatConvertedBitmap fcb = new FormatConvertedBitmap();
fcb.BeginInit();
fcb.Source = bs;
fcb.DestinationFormat = PixelFormats.Gray8;
fcb.EndInit();
// creates WriteableBitmap
WriteableBitmap wb = new WriteableBitmap(fcb);
// shows wb
/*
var image = new System.Windows.Controls.Image { Source = wb };
var window = new System.Windows.Window
{
Title = string.Format("wb (Format:{0})", wb.Format),
Width = wb.PixelWidth,
Height = wb.PixelHeight,
Content = image
};
var app = new System.Windows.Application();
app.Run(window);
//*/
// convert wb into IplImage
IplImage ipl = wb.ToIplImage();
//IplImage ipl32 = new IplImage(wb.PixelWidth, wb.PixelHeight, BitDepth.U16, 1);
//WriteableBitmapConverter.ToIplImage(wb, ipl32);
using (new CvWindow("from WriteableBitmap(Bgr32) to IplImage", ipl))
{
Cv.WaitKey();
}
}