本文整理汇总了C#中System.Drawing.Image.Convert方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Convert方法的具体用法?C# Image.Convert怎么用?C# Image.Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.Convert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreProcess
public override IDataContainer PreProcess(IDataContainer dataContainer)
{
_debugOutputImage = new Image<Rgb, byte>(Width, Height);
var rgbImage = dataContainer.OfType<RgbImageData>().ToArray();
if (!rgbImage.Any()) return null;
_debugOutputImage += rgbImage.First().Image.Copy();
var devices = dataContainer.OfType<Device>().ToArray();
//var unknownDevices = dataContainer.OfType<Device>().Where(d => !d.IsIdentified).ToArray();
var hands = dataContainer.OfType<Hand>().ToArray();
foreach (var device in devices)
{
var polyline = new List<Point>();
foreach (var point in device.Shape.Points)
{
var x = point.X * Width;
var y = point.Y * Height;
polyline.Add(new Point((int)x, (int)y));
}
var centerX = (int)(device.SmoothedCenter.X / 320 * Width);
var centerY = (int)(device.SmoothedCenter.Y / 240 * Height);
_debugOutputImage.DrawPolyline(polyline.ToArray(), true, device.IsIdentified ? Rgbs.Red : Rgbs.White, 5);
if (device.IsIdentified)
_debugOutputImage.Draw(string.Format("Id {0}", device.DeviceId), ref EmguFontBig, new Point(centerX, centerY), Rgbs.Red);
}
foreach (var hand in hands)
{
var resizedHandSegment = hand.Segment.Resize(_debugOutputImage.Width, _debugOutputImage.Height, INTER.CV_INTER_CUBIC).Mul(255);
//_debugOutputImage = _debugOutputImage.Copy(resizedHandSegment.Not());
_debugOutputImage = _debugOutputImage.AddWeighted(resizedHandSegment.Convert<Rgb, byte>(), 1.0, 0.5, 0.0);
resizedHandSegment.Dispose();
var point = new Point((int)(hand.RelativeCenter.X * Width), (int)(hand.RelativeCenter.Y * Height));
var labelPoint = new Point((int)(hand.RelativeCenter.X * Width + 30), (int)(hand.RelativeCenter.Y * Height));
_debugOutputImage.Draw(new CircleF(point, 10), Rgbs.Red, 6);
_debugOutputImage.Draw(string.Format("Id {0} (d={1:F0})", hand.Id, hand.Depth), ref EmguFontBig, labelPoint, Rgbs.Red);
}
var debugOutputImageCopy = _debugOutputImage.Copy();
Task.Factory.StartNew(() =>
{
var bitmapSource = debugOutputImageCopy.ToBitmapSource(true);
debugOutputImageCopy.Dispose();
return bitmapSource;
}).ContinueWith(t => DebugOutputBitmapSource = t.Result);
Stage(new RgbImageData(this, "DataRenderer", _debugOutputImage.Copy()));
if (_videoWriter != null)
_videoWriter.WriteFrame(_debugOutputImage.Convert<Bgr, byte>());
_debugOutputImage.Dispose();
Push();
return base.PreProcess(dataContainer);
}
示例2: ConvertFromBgr
/// <summary>
/// Method to convert an image bgr type to an image hsv type
/// </summary>
/// <param name="bgrFrame">Image Bgr type</param>
/// <returns>Image HsvType</returns>
public Image<Hsv, byte> ConvertFromBgr(Image<Bgr, byte> bgrFrame)
{
Image<Hsv, byte> _hsvImg = bgrFrame.Convert<Hsv, byte>(); // Convert it to HSV format
//CvInvoke.cvCvtColor(bgrFrame.Ptr, bgrFrame.Ptr, Emgu.CV.CvEnum.COLOR_CONVERSION.BGR2HSV);
return _hsvImg;
}
示例3: ProcessAndView
public override Image<Rgb, byte> ProcessAndView(Image<Rgb, byte> image)
{
var outputImage = new Image<Hsv, double>(image.Width, image.Height);
// draw gradient legend
for (var cx = 0; cx < outputImage.Width; cx++)
{
var c = new Hsv(120.0 - (cx / (double)outputImage.Width * 120.0), 255.0, 255.0);
outputImage[0, cx] = c;
outputImage[1, cx] = c;
outputImage[2, cx] = c;
}
// draw depth values as HSV
for (var y = 3; y < outputImage.Height; y++)
{
for (var x = 0; x < outputImage.Width; x++)
{
// TODO fix me!!
var cin = 1000; //image[y, x].Intensity;
if (cin >= MinReproducedDepth && cin <= MaxReproducedDepth)
{
var h = 120.0 - ((cin - MinReproducedDepth) / (MaxReproducedDepth - MinReproducedDepth) * 120.0);
outputImage[y, x] = new Hsv(h, 255.0, 255.0);
}
else
outputImage[y, x] = new Hsv(0.0, 0.0, 0.0);
}
}
var message = outputImage.Width + " x " + outputImage.Height + " [rd: " + MinReproducedDepth + " ," + MaxReproducedDepth + "]";
outputImage.Draw(message, ref EmguFont, new Point(5, 15), new Hsv(0, 0, 0));
return outputImage.Convert<Rgb, byte>();
}