Пример #1
0
        // foamliu, 2009/02/01, 处理后所有点的灰度值有:
        //     gmin <= g <= gmax
        //
        //  Notes: 或者为0.
        public static Bitmap ThresholdSimple(Bitmap bmp, int gmin, int gmax)
        {
            int width, height;

            int[][] mat;
            Bitmap  newBmp;

            ImageConvert.Bitmap2Mat(bmp, out mat, out width, out height);
            ThresholdLib.ThresholdSimple(mat, gmin, gmax);
            ImageConvert.Mat2Bitmap(mat, width, height, out newBmp);

            return(newBmp);
        }
Пример #2
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);
        }