Variance filter.
The Variance filter replaces each pixel in an image by its neighborhood variance. The end result can be regarded as an border enhancement, making the Variance filter suitable to be used as an edge detection mechanism.
Inheritance: BaseFilter
Example #1
0
        public void ProcessImageTest()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;
            new MatrixToImage().Convert(diag, out input);

            // Create a new Variance filter
            Variance filter = new Variance();

            // Apply the filter
            Bitmap output = filter.Apply(input);

            double[,] actual; 
            
            new ImageToMatrix().Convert(output, out actual);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected = 
            {
                { 0, 0, 0, 0, 0 },
                { 0.0941176470588235, 0.545098039215686, 0.396078431372549, 0.376470588235294, 0.192156862745098 },
                { 0.298039215686275, 0.376470588235294, 0.27843137254902, 0.211764705882353, 0.133333333333333 },
                { 0.317647058823529, 0.203921568627451, 0.2, 0.16078431372549, 0.109803921568627 },
                { 0.0509803921568627, 0.109803921568627, 0.16078431372549, 0.2, 0.203921568627451 } 
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }
Example #2
0
 public void VarianceTest1()
 {
     Bitmap image = Accord.Imaging.Image.Clone(Properties.Resources.lena512);
     Variance variance = new Variance();
     Bitmap result = variance.Apply(image);
     Assert.IsNotNull(result);
 }
Example #3
0
 public void VarianceTest1()
 {
     Bitmap image = Properties.Resources.lena512;
     Variance variance = new Variance();
     Bitmap result = variance.Apply(image);
     Assert.IsNotNull(result);
 }
Example #4
0
 private void SetFilter()
 {
     if (fast)
     {
         ImageType = ImageTypes.Rgb24bpp;
         Af.FastVariance newFilter = new Af.FastVariance();
         newFilter.Radius = radius;
         imageFilter      = newFilter;
     }
     else
     {
         ImageType = ImageTypes.Rgb24bpp;
         Af.Variance newFilter = new Af.Variance();
         newFilter.Radius = radius;
         imageFilter      = newFilter;
     }
 }