Пример #1
0
        public static Mat GetSobelY(Mat source, BorderWrapType borderWrapType)
        {
            Mat dy = source.Clone();

            ConvolutionHelper.NonSeparable(source, dy, SobelKernelY, borderWrapType);
            return(dy);
        }
Пример #2
0
        public static Mat SobelNonSeparable(Mat source, Mat dx, Mat dy)
        {
            ConvolutionHelper.NonSeparable(source, dx, SobelKernelX, BorderWrapType.Copy);
            ConvolutionHelper.NonSeparable(source, dy, SobelKernelY, BorderWrapType.Copy);

            var target = new Mat(source.Width, source.Height);

            for (var x = 0; x < source.Width; x++)
            {
                for (var y = 0; y < source.Height; y++)
                {
                    target.Set(x, y, MathHelper.SqrtOfSqrSum(dx.GetAt(x, y), dy.GetAt(x, y)));
                }
            }

            return(target);
        }
Пример #3
0
        public static Mat Sobel(Mat source, BorderWrapType borderWrapType)
        {
            Mat dx = new Mat(), dy = new Mat();

            ConvolutionHelper.Separable(source, dx, SobelKernelA, borderWrapType);
            ConvolutionHelper.Separable(source, dy, SobelKernelB, borderWrapType);

            var target = new Mat(source.Width, source.Height);

            for (var x = 0; x < source.Width; x++)
            {
                for (var y = 0; y < source.Height; y++)
                {
                    target.Set(x, y, MathHelper.SqrtOfSqrSum(dx.GetAt(x, y), dy.GetAt(x, y)));
                }
            }

            return(target);
        }