コード例 #1
0
        public static void ErodeUnsafe(int iteration, bool useParallel)
        {
            Glb.DrawMatAndHist0(Glb.matSrc);

            var matGray = Glb.matSrc.CvtColor(ColorConversionCodes.BGR2GRAY);

            Glb.DrawMatAndHist1(matGray);

            Glb.TimerStart();
            var matDst = new Mat(matGray.Size(), matGray.Type());

            for (int i = 0; i < iteration; i++)
            {
                if (i % 2 == 0)
                {
                    IpUnsafe.Erode(matGray.Data, matDst.Data, matGray.Width, matGray.Height, (int)matGray.Step(), useParallel);
                }
                else
                {
                    IpUnsafe.Erode(matDst.Data, matGray.Data, matGray.Width, matGray.Height, (int)matGray.Step(), useParallel);
                }
            }
            if (iteration != 0 && iteration % 2 == 0)
            {
                matGray.CopyTo(matDst);
            }

            Console.WriteLine("=> Method Time: {0}ms", Glb.TimerStop());
            Glb.DrawMatAndHist2(matDst);

            matGray.Dispose();
            matDst.Dispose();
        }
コード例 #2
0
        public static Mat ErodeUnsafe(Mat matGray, int iteration, bool useParallel)
        {
            var mat0 = matGray.Clone();
            var mat1 = new Mat(mat0.Size(), mat0.Type());

            for (int i = 0; i < iteration; i++)
            {
                var matSrc = (i % 2 == 0) ? mat0 : mat1;
                var matDst = (i % 2 == 0) ? mat1 : mat0;
                IpUnsafe.Erode(matSrc.Data, matDst.Data, matGray.Width, matGray.Height, (int)matGray.Step(), useParallel);
            }
            return((iteration % 2 == 0) ? mat0 : mat1);
        }