예제 #1
0
        /// <summary>
        /// 画像に横方向のプリューウィットフィルタを適用
        /// </summary>
        /// <param name="sourceImage">画像の2次元配列</param>
        /// <returns>フィルタ適用後の画像の2次元配列</returns>
        public static double[,] ApplyHorizontalPrewittFilter(byte[,] sourceImage)
        {
            double[,] filter = new double[3, 3] {
                { -1.0 / 6.0, 0.0, 1.0 / 6.0 },
                { -1.0 / 6.0, 0.0, 1.0 / 6.0 },
                { -1.0 / 6.0, 0.0, 1.0 / 6.0 }
            };

            return(ImageFiltering.ApplyFilterAllowNegativeValues(sourceImage, filter));
        }
예제 #2
0
        /// <summary>
        /// 画像に縦方向のソーベルフィルタを適用
        /// </summary>
        /// <param name="sourceImage">画像の2次元配列</param>
        /// <returns>フィルタ適用後の画像の2次元配列</returns>
        public static double[,] ApplyVerticalSobelFilter(byte[,] sourceImage)
        {
            double[,] filter = new double[3, 3] {
                { 1.0 / 8.0, 2.0 / 8.0, 1.0 / 8.0 },
                { 0.0, 0.0, 0.0 },
                { -1.0 / 8.0, -2.0 / 8.0, -1.0 / 8.0 }
            };

            return(ImageFiltering.ApplyFilterAllowNegativeValues(sourceImage, filter));
        }
예제 #3
0
        /// <summary>
        /// 画像に縦方向の微分フィルタを適用
        /// </summary>
        /// <param name="sourceImage">画像の2次元配列</param>
        /// <returns>フィルタ適用後の画像の2次元配列</returns>
        public static double[,] ApplyVerticalDerivativeFilter(byte[,] sourceImage)
        {
            double[,] filter = new double[3, 3] {
                { 0.0, 0.5, 0.0 },
                { 0.0, 0.0, 0.0 },
                { 0.0, -0.5, 0.0 }
            };

            return(ImageFiltering.ApplyFilterAllowNegativeValues(sourceImage, filter));
        }
예제 #4
0
        /// <summary>
        /// 画像にLoG(Laplacian of Gaussian)フィルタを適用
        /// </summary>
        /// <param name="sourceImage">画像の2次元配列</param>
        /// <param name="filterSize">フィルタのサイズ</param>
        /// <param name="standardDeviation">ガウス分布の標準偏差</param>
        /// <returns>フィルタ適用後の画像の2次元配列</returns>
        public static double[,] ApplyLoGFilter(byte[,] sourceImage, int filterSize, double standardDeviation)
        {
            Debug.Assert(filterSize % 2 == 1);

            double[,] filter = new double[filterSize, filterSize];

            for (int m = 0; m < filterSize; ++m)
            {
                for (int n = 0; n < filterSize; ++n)
                {
                    double r = Math.Pow(m - (filterSize / 2), 2.0) + Math.Pow(n - (filterSize / 2), 2.0);
                    filter[m, n] = Math.Exp(-r / (2.0 * Math.Pow(standardDeviation, 2.0))) *
                                   (r - 2.0 * Math.Pow(standardDeviation, 2.0)) /
                                   (2.0 * Math.PI * Math.Pow(standardDeviation, 6.0));
                }
            }

            return(ImageFiltering.ApplyFilterAllowNegativeValues(sourceImage, filter));
        }