Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }