コード例 #1
0
ファイル: ImageProcess.cs プロジェクト: linuxbank/PLOCR
        public static Bitmap thick(Bitmap source)        // 선 굵게, 24비트로 넣어줘야함
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            int order = int.Parse(ini.GetIniValue("선굵기값", "굵게횟수"));

            for (int i = 0; i < order; i++)
            {
                Bitmap tmp = (Bitmap)source;        // 중요! 한번 이미지 처리가 끝난 비트맵 source 는 clone 함수로 보내기 전에 다시 한번 (Bitmap) 처리 해줘야함, 이유는 잘 모르겠음
                // convert to 24 bits per pixel
                source = ImageProcess.Clone(tmp, PixelFormat.Format24bppRgb);
                // delete old image
                tmp.Dispose();

                Erosion filter = new Erosion();
                filter.ApplyInPlace(source);;
            }

            return(source);
        }
コード例 #2
0
ファイル: ImageProcess.cs プロジェクト: linuxbank/PLOCR
        public static Bitmap skew(Bitmap source)        // 기울어짐 바로잡기
        {
            // create grayscale filter (BT709)
            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);       // 8비트 grayscale 로 바꾸고
            // apply the filter
            Bitmap grayImage = filter.Apply(source);

            // create instance of skew checker
            DocumentSkewChecker skewChecker = new DocumentSkewChecker(); // 8비트 grayscale 로 넣어줘야 함
            //    // get documents skew angle
            double angle = skewChecker.GetSkewAngle(grayImage);          // 기울어진 각도를 얻고

            Bitmap tmp = source;

            // convert to 24 bits per pixel
            source = ImageProcess.Clone(tmp, PixelFormat.Format24bppRgb);       // 로테이션 전에 24비트로 바꿔주고
            // delete old image
            tmp.Dispose();

            // create rotation filter
            RotateBilinear rotationFilter = new RotateBilinear(-angle);

            rotationFilter.FillColor = Color.White;
            // rotate image applying the filter
            Bitmap rotatedImage = rotationFilter.Apply(source);  // 원래 이미지를 가져다가 각도만큼 돌리고(원래 이미지는 24비트로 넣어줘야함)

            return(rotatedImage);
        }
コード例 #3
0
ファイル: ImageProcess.cs プロジェクト: linuxbank/PLOCR
        public static Bitmap invert(Bitmap source) // 반전
        {
            Bitmap tmp = (Bitmap)source;           // 중요! 한번 이미지 처리가 끝난 비트맵 source 는 clone 함수로 보내기 전에 다시 한번 (Bitmap) 처리 해줘야함, 이유는 잘 모르겠음

            // convert to 24 bits per pixel
            source = ImageProcess.Clone(tmp, PixelFormat.Format24bppRgb);
            // delete old image
            tmp.Dispose();

            Invert invertfilter = new Invert();

            invertfilter.ApplyInPlace(source);

            return(source);
        }
コード例 #4
0
ファイル: calculator.cs プロジェクト: linuxbank/PLOCR
        public static Bitmap imgProcess(Bitmap source, string callFunction)  // 지정된 이미지 처리를 한다.
        {
            if (callFunction == "색상 필터")
            {
                Global.source = ImageProcess.colorFilter(source);
            }
            else if (callFunction == "색상 반전")
            {
                Global.source = ImageProcess.invert(source);
            }
            else if (callFunction == "선 굵게")
            {
                Global.source = ImageProcess.thick(source);
            }
            else if (callFunction == "선 가늘게")
            {
                Global.source = ImageProcess.thin(source);
            }
            else if (callFunction == "밝게")
            {
                Global.source = ImageProcess.bright(source);
            }
            else if (callFunction == "어둡게")
            {
                Global.source = ImageProcess.dark(source);
            }
            else if (callFunction == "기울어짐 바로잡기")
            {
                Global.source = ImageProcess.skew(source);
            }
            else if (callFunction == "원본")
            {
                string path = @"C:\Program Files\PLOCR\prescription.png";
                Global.source = (Bitmap)Bitmap.FromFile(path);
            }
            else
            {
            }

            return(Global.source);
        }