Exemplo n.º 1
0
        public MedianFilter(int maskSize)
        {
            ValidationUtils.IsMaskSize(maskSize);

            Range  = maskSize / 2;
            Center = maskSize * maskSize / 2;
        }
Exemplo n.º 2
0
        private void Validate(int maskSize, int[] thresholds)
        {
            ValidationUtils.IsMaskSize(maskSize);

            if (thresholds.Length != (maskSize * maskSize - 1) / 2)
            {
                throw new ArgumentException("Thresholds must contain (maskSize ^ 2 - 1) / 2 elements");
            }
        }
        private static void Validate(int range, int levels)
        {
            ValidationUtils.IsMaskSize(range);

            if (levels <= 0)
            {
                throw new ArgumentException("Levels value has to be positive");
            }
        }
        public static Image <Pixel1> Dilation(this Image <Pixel1> image, int maskSize = 3)
        {
            ValidationUtils.IsMaskSize(maskSize);

            var range         = maskSize / 2;
            var currentIndex  = maskSize * maskSize / 2;
            var originalImage = image.Copy();

            originalImage.ForEachNeighbourhood(range, (x, y, neighbourhood) =>
            {
                var newValue = false;
                for (int i = 0; i < neighbourhood.Length; i++)
                {
                    if (i != currentIndex && neighbourhood[i].Value)
                    {
                        newValue = true;
                        break;
                    }
                }
                image.Set(x, y, new Pixel1(newValue));
            });
            return(image);
        }
 public KuwaharaFilter(int maskSize)
 {
     ValidationUtils.IsMaskSize(maskSize);
     Range = maskSize / 2;
 }