コード例 #1
0
        /// <summary>
        /// foamliu, 2009/02/09, 二值图像求逆
        ///
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        public static Bitmap Inverse(Bitmap bmp)
        {
            int width, height;

            int[][] mat;
            Bitmap  newBmp;

            ImageConvert.Bitmap2Mat(bmp, out mat, out width, out height);
            ImageConvert.GrayValue2Binary(mat);

            BinaryImageLib.Inverse(mat);

            ImageConvert.Binary2GrayValue(mat);
            ImageConvert.Mat2Bitmap(mat, width, height, out newBmp);

            return(newBmp);
        }
コード例 #2
0
        /// <summary>
        /// foamliu, 2009/02/09, 二值图像闭操作
        ///
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        public static Bitmap BinaryClose(Bitmap bmp)
        {
            int width, height;

            int[][] mat, filtered;
            Bitmap  newBmp;

            ImageConvert.Bitmap2Mat(bmp, out mat, out width, out height);
            ImageConvert.GrayValue2Binary(mat);

            BinaryImageLib.Close(mat, StructuringElement.N4, out filtered);

            ImageConvert.Binary2GrayValue(filtered);
            ImageConvert.Mat2Bitmap(filtered, width, height, out newBmp);

            return(newBmp);
        }
コード例 #3
0
        public static Bitmap ThresholdDynamic(Bitmap bmp, int gdiff, int k)
        {
            int width, height;

            int[][] mat;
            Bitmap  newBmp;

            ImageConvert.Bitmap2Mat(bmp, out mat, out width, out height);

            ThresholdLib.ThresholdDynamic(mat, gdiff, k);

            // foamliu, 2009/02/04, 阈值化的结果是二值图像, 需要转化为可显示的灰度图.
            ImageConvert.Binary2GrayValue(mat);

            ImageConvert.Mat2Bitmap(mat, width, height, out newBmp);

            return(newBmp);
        }