Пример #1
0
        public Bitmap Apply(Bitmap image, KassWitkinKernel kernel)
        {
            Complex[,] cImagePadded  = ImageDataConverter.ToComplex(image);
            Complex[,] cKernelPadded = kernel.ToComplexPadded();
            Complex[,] convolved     = Convolution.Convolve(cImagePadded, cKernelPadded);

            return(ImageDataConverter.ToBitmap(convolved));
        }
Пример #2
0
        public List <Bitmap> Apply(Bitmap bitmap)
        {
            Kernels = new List <KassWitkinKernel>();

            double degrees = FilterAngle;

            KassWitkinKernel kernel;

            for (int i = 0; i < NoOfFilters; i++)
            {
                kernel               = new KassWitkinKernel();
                kernel.Width         = KernelDimension;
                kernel.Height        = KernelDimension;
                kernel.CenterX       = (kernel.Width) / 2;
                kernel.CenterY       = (kernel.Height) / 2;
                kernel.Du            = 2;
                kernel.Dv            = 2;
                kernel.ThetaInRadian = Tools.DegreeToRadian(degrees);
                kernel.Compute();

                //SleuthEye
                kernel.Pad(kernel.Width, kernel.Height, WidthWithPadding, HeightWithPadding);

                Kernels.Add(kernel);

                degrees += degrees;
            }

            List <Bitmap> list = new List <Bitmap>();

            Bitmap image = (Bitmap)bitmap.Clone();

            Complex[,] cImagePadded = ImageDataConverter.ToComplex(image);
            FourierTransform ftForImage = new FourierTransform(cImagePadded); ftForImage.ForwardFFT();

            Complex[,] fftImage = ftForImage.FourierImageComplex;

            foreach (KassWitkinKernel k in Kernels)
            {
                Complex[,] cKernelPadded = k.ToComplexPadded();
                Complex[,] convolved     = Convolution.ConvolveInFrequencyDomain(fftImage, cKernelPadded);

                Bitmap temp = ImageDataConverter.ToBitmap(convolved);
                list.Add(temp);
            }

            return(list);
        }