示例#1
0
        /// <summary>
        /// Applies Canny filter on specified image. (uses AForge implementation)
        /// </summary>
        /// <param name="im">image</param>
        /// <param name="lowThreshold">Low threshold value used for hysteresis</param>
        /// <param name="highThreshold">High threshold value used for hysteresis</param>
        /// <param name="sigma">Gaussian sigma</param>
        /// <param name="gaussianSize">Gaussian filter size</param>
        /// <returns>Processed image with Canny filter</returns>
        public static Gray <byte>[,] Canny(this Gray <byte>[,] im, byte lowThreshold = 20, byte highThreshold = 100, double sigma = 1.4, int gaussianSize = 5)
        {
            CannyEdgeDetector canny = new CannyEdgeDetector(lowThreshold, highThreshold, sigma);

            canny.GaussianSize = gaussianSize;

            return(im.ApplyFilter(canny));
        }
        /// <summary>
        /// Adjusts pixels' contrast value by increasing RGB values of bright pixel and decreasing
        /// pixel values of dark pixels (or vise versa if contrast needs to be decreased).
        /// </summary>
        /// <param name="im">Image.</param>
        /// <param name="factor">Factor which is used to adjust contrast. Factor values greater than
        /// 0 increase contrast making light areas lighter and dark areas darker. Factor values
        /// less than 0 decrease contrast - decreasing variety of contrast.</param>
        /// <param name="inPlace">Process in place or make not. If in place is set to true, returned value may be discarded.</param>
        /// <returns>Corrected image.</returns>
        public static Gray <byte>[,] CorrectContrast(this Gray <byte>[,] im, int factor = 10, bool inPlace = false)
        {
            ContrastCorrection conrastCorrection = new ContrastCorrection(factor);

            return(im.ApplyFilter(conrastCorrection, inPlace));
        }
        /// <summary>
        /// Stretches intensity values in a linear way across full pixel range.
        /// </summary>
        /// <param name="im">Image.</param>
        /// <param name="inPlace">Process in place or make not. If in place is set to true, returned value may be discarded.</param>
        /// <returns>Corrected image.</returns>
        public static Gray <byte>[,] StretchContrast(this Gray <byte>[,] im, bool inPlace = false)
        {
            ContrastStretch conrastStrech = new ContrastStretch();

            return(im.ApplyFilter(conrastStrech, inPlace));
        }