当前位置: 首页>>代码示例>>C#>>正文


C# Mat.ConvertTo方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:rachwal,项目名称:RTM-Tools,代码行数:14,代码来源:CPUDisparitySolver.cs

示例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);
      }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:47,代码来源:HistogramBox.cs

示例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);
            }
        }
开发者ID:rachwal,项目名称:RTM-Tools,代码行数:27,代码来源:GPUDisparitySolver.cs


注:本文中的Emgu.CV.Mat.ConvertTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。