예제 #1
0
 public void SetValue(double v)
 {
     var mtx = new[,]
                   {
                       {-v, -v, -v},
                       {-v, 8*v + 1, -v},
                       {-v, -v, -v}
                   };
     filter = new ConvolutionFilter(mtx, 1, 0);
 }
예제 #2
0
        public void SetValue(double v)
        {
            double r = (v/360*Math.PI)*2, dr = Math.PI/4;

            var mtx = new[,]
                          {
                              {Math.Cos(r + dr), Math.Cos(r + 2*dr), Math.Cos(r + 3*dr)},
                              {Math.Cos(r), 0, Math.Cos(r + 4*dr)},
                              {Math.Cos(r - dr), Math.Cos(r - 2*dr), Math.Cos(r - 3*dr)}
                          };
            filter = new ConvolutionFilter(mtx, 1, 0);
        }
예제 #3
0
        public void SetValue(int size, double sig)
        {
            if (size%2 == 1)
            {
                sigma = sig;
                var mtx = new double[size,size];
                int radius = size/2;
                int x = -radius;
                for (int i = 0; i < size; i++, x++)
                {
                    int y = -radius;
                    for (int j = 0; j < size; y++, j++)
                    {
                        mtx[i, j] = fn(x, y);
                    }
                }

                filter = new ConvolutionFilter(mtx);
            }
            else
                throw new ArgumentException("Matrix Dimension should be Odd...");
        }
예제 #4
0
 public IFilter AddFilterFromString(string filterName)
 {
     IFilter filter = null;
     switch (filterName.ToLowerInvariant())
     {
         case "alpha":
             filter = new AlphaFilter();
             break;
         case "blind":
             filter = new BlindFilter();
             break;
         case "brightness":
             filter = new BrightnessFilter();
             break;
         case "channel":
             filter = new ChannelFilter();
             break;
         case "contrast":
             filter = new ContrastFilter();
             break;
         case "duotone":
             filter = new DuotoneFilter();
             break;
         case "exposure":
             filter = new ExposureFilter();
             break;
         case "grayscale":
             filter = new GrayscaleFilter();
             break;
         case "hue":
             filter = new HueFilter();
             break;
         case "invert":
             filter = new InvertFilter();
             break;
         case "saturate":
             filter = new SaturateFilter();
             break;
         case "temp":
             filter = new TempFilter();
             break;
         case "threshold":
             filter = new ThresholdFilter();
             break;
         case "tint":
             filter = new TintFilter();
             break;
         case "convolution":
             filter = new ConvolutionFilter();
             break;
         case "edgedetect":
             filter = new EdgeDetectFilter();
             break;
         case "emboss":
             filter = new EmbossFilter();
             break;
         case "gaussian":
             filter = new GaussianBlurFilter();
             break;
         case "relief":
             filter = new ReliefFilter();
             break;
         case "sharpness":
             filter = new SharpnessFilter();
             break;
         case "basedisplacement":
             filter = new BaseDisplacementFilter();
             break;
         case "flip":
             filter = new FlipFilter();
             break;
         case "jitter":
             filter = new JitterFilter();
             break;
         case "pixelate":
             filter = new PixelateFilter();
             break;
         case "sphere":
             filter = new SphereFilter();
             break;
         case "timewrap":
             filter = new TimeWrapFilter();
             break;
         case "water":
             filter = new WaterFilter();
             break;
         default:
             new Exception(string.Format("Filter '{0}' doesn't exists.", filterName));
             break;
     }
     filterChain.Add(filter);
     return filter;
 }