Пример #1
0
        public static void Process(this IDirectBitmap bitmap, int radius)
        {
            using (var original = (IDirectBitmap) bitmap.Clone())
            {
                Parallel.ForEach(Enumerable.Range(0, bitmap.Height),
                    new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount}, y =>
                    {
                        var random = new Random(y);
                        for (var x = 0; x < bitmap.Width; x++)
                        {

                            int x1 =
                                DirectBitmapExtensionBase.NormalizeBounds(
                                    (int) (x + (random.Next(1000) / 1000.0 - 0.5) * radius), 0,
                                    bitmap.Width);
                            int y1 =
                                DirectBitmapExtensionBase.NormalizeBounds(
                                    (int) (y + (random.Next(1000) / 1000.0 - 0.5) * radius), 0,
                                    bitmap.Height);
                            var c = original.GetPixel(x, y);
                            bitmap.SetPixel(x1, y1, c);
                        }
                    });
            }

        }
Пример #2
0
        public static void Process(this IDirectBitmap bitmap, double sigma)
        {
            var kerRow = Kernel.GaussRowKernel(sigma);
            var kerCol = Kernel.GaussColumnKernel(sigma);
            DirectBitmapExtensionBase.ApplyConvolutionFilter(bitmap, kerRow);
            DirectBitmapExtensionBase.ApplyConvolutionFilter(bitmap, kerCol);

        }