예제 #1
0
 private void SetMatrix(SobelDirection direction)
 {
     if (direction == SobelDirection.X)
     {
         filterMatrix = new double[, ] {
             { -1.0, 0.0, 1.0 }, { -2.0, 0.0, 2.0 }, { -1.0, 0.0, 1.0 }
         };
     }
     else if (direction == SobelDirection.Y)
     {
         filterMatrix = new double[, ] {
             { -1.0, -2.0, -1.0 }, { 0.0, 0.0, 0.0 }, { 1.0, 2.0, 1.0 }
         };
     }
     else
     {
         throw new ArgumentOutOfRangeException("Error: Direction should either be X or Y for image dimension");
     }
 }
예제 #2
0
        public SobelEdgeDetectFilter(SobelDirection direction, bool isImageInColor)
        {
            this._isImageInColor = isImageInColor;

            switch (direction)
            {
            case SobelDirection.Vertical:
                this._kernel = _verticalEdgeKernel;
                break;

            case SobelDirection.Horizontal:
                this._kernel = _horizontalEdgeKernel;
                break;

            case SobelDirection.Both:
                this._isDirectionBoth = true;
                break;
            }
        }
예제 #3
0
 public SobelFilter(SobelDirection direction, int dimX = 3, int dimY = 3) : base(dimX, dimY)
 {
     SetMatrix(direction);
     this.Direction = direction;
 }