Esempio n. 1
0
        private void ConstructKernels(CompassType type)
        {
            int i = 0;

            kernels = new BasicKernel[8];
            switch (type)
            {
            case CompassType.Approximation:
                foreach (Direction compass in Enum.GetValues(typeof(Direction)))
                {
                    kernels[i] = new ApproximationKernel(null, compass);
                    i++;
                }
                break;

            case CompassType.Isotropic:
                foreach (Direction compass in Enum.GetValues(typeof(Direction)))
                {
                    kernels[i] = new IsotropicKernel(null, compass);
                    i++;
                }
                break;

            case CompassType.Kirsch:
                foreach (Direction compass in Enum.GetValues(typeof(Direction)))
                {
                    kernels[i] = new KirschKernel(null, compass);
                    i++;
                }
                break;

            case CompassType.Prewitt:
                foreach (Direction compass in Enum.GetValues(typeof(Direction)))
                {
                    kernels[i] = new PrewittKernel(null, compass);
                    i++;
                }
                break;

            case CompassType.Sobel:
                foreach (Direction compass in Enum.GetValues(typeof(Direction)))
                {
                    kernels[i] = new SobelKernel(null, compass);
                    i++;
                }
                break;

            default:
                throw new InvalidOperationException("You cannot perform a CompassOperation on the specified CompassType.");
            }
        }
Esempio n. 2
0
 public ApproximationKernel(IApplicableFilter decoratingKernel, Direction compass)
     : base(decoratingKernel, 3, 3, ApproximationKernel.constructWeights(3, 3, compass))
 {
     // A snail can sleep for 3 years.
 }