Exemplo n.º 1
0
        private void back(Bitmap originImg)
        {
            //如果只有两种颜色,则是文本阅读模式。直接识别
            //如果颜色驳杂,则说明是看动漫模式。用下面这种
            // OpenCVTest(originImg);
            originImg.Save("origin.jpg");

            /*
             * Bitmap sharpBlackImg = MoveGreyToWhite(originImg);
             * sharpBlackImg.Save("sharpBlack.jpg");
             */

            Bitmap grey1            = ToGrey(originImg);
            Bitmap blackWhiteOrigin = Thresholding(grey1);

            blackWhiteOrigin.Save("blackWhiteOrigin.jpg");

            BitmapRegion bitmapRegion = new BitmapRegion(originImg);

            bitmapRegion.Regionalize();
            bitmapRegion.CalColorPropForRegions();
            Bitmap regionImage = bitmapRegion.DrawAndGetImage();

            regionImage.Save("region.jpg");

            Bitmap greyImg = ToGrey(regionImage);

            greyImg.Save("grey.jpg");


            int    minR    = 0;
            Bitmap edgeImg = BitmapUtil.ToEdgeImg(originImg, out minR);

            edgeImg.Save("edge.jpg");


            var fontColor = GetFontStrokeColor(originImg, edgeImg, minR);



            Bitmap blackWhiteImg = Thresholding(regionImage);
            Bitmap blackAlphaImg = ReverseColor(blackWhiteImg);

            blackAlphaImg.Save("blackAlpha.jpg");

            Bitmap cleanImg = BitmapUtil.CleanEdgeSpot(blackAlphaImg);

            cleanImg.Save("clean.jpg");
        }
Exemplo n.º 2
0
        private Bitmap GetCleanImg(Bitmap originImg)
        {
            int minR = 0;

            Bitmap edgeImg = BitmapUtil.ToEdgeImg(originImg, out minR);

            //todo 强化文字行部分的edge
            var fontStrokeColor = GetFontStrokeColor(originImg, edgeImg, minR);
            var fontColor       = fontStrokeColor.Item1;
            var strokeColor     = fontStrokeColor.Item2;

            Bitmap strokeBackImg = BitmapUtil.RenderBackgroundToStrokeColor(originImg, strokeColor);

            Bitmap blackFontImg = RemainFontAsBlackColor(strokeBackImg, fontColor);

            originImg.Save("origin.jpg");
            edgeImg.Save("edge.jpg");
            strokeBackImg.Save("strokeBack.jpg");
            blackFontImg.Save("blackFont.jpg");

            return(blackFontImg);
        }