本文整理汇总了C#中Emgu.CV.Mat.ConvertTo方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.ConvertTo方法的具体用法?C# Mat.ConvertTo怎么用?C# Mat.ConvertTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu.CV.Mat
的用法示例。
在下文中一共展示了Mat.ConvertTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Solve
public Image<Gray, byte> Solve(Image<Gray, byte> left, Image<Gray, byte> right)
{
using (var disparity16S = new Mat(left.Size, DepthType.Cv16S, 1))
using (var disparity8U = new Mat(left.Size, DepthType.Cv8U, 1))
{
algorithm.Compute(left, right, disparity16S);
CvInvoke.MinMaxLoc(disparity16S, ref min, ref max, ref minPosition, ref maxPosition);
disparity16S.ConvertTo(disparity8U, DepthType.Cv8U, 255.0/(Max - Min));
return new Image<Gray, byte>(disparity8U.Bitmap);
}
}
示例2: AddHistogram
/// <summary>
/// Add a plot of the 1D histogram. You should call the Refresh() function to update the control after all modification is complete.
/// </summary>
/// <param name="name">The name of the histogram</param>
/// <param name="color">The drawing color</param>
/// <param name="histogram">The 1D histogram to be drawn</param>
/// <param name="binSize">The size of the bin</param>
/// <param name="ranges">The ranges</param>
public void AddHistogram(String name, Color color, Mat histogram, int binSize, float[] ranges)
{
//Debug.Assert(histogram.Dimension == 1, Properties.StringTable.Only1DHistogramSupported);
GraphPane pane = new GraphPane();
// Set the Title
pane.Title.Text = name;
pane.XAxis.Title.Text = Properties.StringTable.Value;
pane.YAxis.Title.Text = Properties.StringTable.Count;
#region draw the histogram
RangeF range = new RangeF(ranges[0], ranges[1]);
float step = (range.Max - range.Min) / binSize;
float start = range.Min;
double[] bin = new double[binSize];
for (int binIndex = 0; binIndex < binSize; binIndex++)
{
bin[binIndex] = start;
start += step;
}
double[] binVal = new double[histogram.Size.Height];
GCHandle handle = GCHandle.Alloc(binVal, GCHandleType.Pinned);
using (Matrix<double> m = new Matrix<double>(binVal.Length, 1, handle.AddrOfPinnedObject(), sizeof(double)))
{
histogram.ConvertTo(m, DepthType.Cv64F);
PointPairList pointList = new PointPairList(
bin,
binVal);
pane.AddCurve(name, pointList, color);
}
handle.Free();
#endregion
zedGraphControl1.MasterPane.Add(pane);
}
示例3: Solve
public Image<Gray, byte> Solve(Image<Gray, byte> left, Image<Gray, byte> right)
{
var size = left.Size;
using (var leftGpu = new GpuMat(left.Rows, left.Cols, DepthType.Cv16S, 1))
using (var rightGpu = new GpuMat(left.Rows, left.Cols, DepthType.Cv16S, 1))
using (var disparityGpu = new GpuMat(left.Rows, left.Cols, DepthType.Cv16S, 1))
using (var filteredDisparityGpu = new GpuMat(left.Rows, left.Cols, DepthType.Cv16S, 1))
using (var filteredDisparity16S = new Mat(size, DepthType.Cv16S, 1))
using (var filteredDisparity8U = new Mat(size, DepthType.Cv8U, 1))
{
leftGpu.Upload(left.Mat);
rightGpu.Upload(right.Mat);
algorithm.FindStereoCorrespondence(leftGpu, rightGpu, disparityGpu);
filter.Apply(disparityGpu, leftGpu, filteredDisparityGpu);
filteredDisparityGpu.Download(filteredDisparity16S);
CvInvoke.MinMaxLoc(filteredDisparity16S, ref min, ref max, ref minPosition, ref maxPosition);
filteredDisparity16S.ConvertTo(filteredDisparity8U, DepthType.Cv8U, 255.0/(Max - Min));
return new Image<Gray, byte>(filteredDisparity8U.Bitmap);
}
}