Esempio n. 1
0
        public UnmanagedImage Apply(UnmanagedImage image)
        {
            UnmanagedImage unmanagedImage = errosion.Apply(image);

            dilatation.ApplyInPlace(unmanagedImage);
            return(unmanagedImage);
        }
Esempio n. 2
0
        /// <summary>
        /// Apply filter to an image in unmanaged memory.
        /// </summary>
        ///
        /// <param name="image">Source image in unmanaged memory to apply filter to.</param>
        ///
        /// <returns>Returns filter's result obtained by applying the filter to
        /// the source image.</returns>
        ///
        /// <remarks>The method keeps the source image unchanged and returns
        /// the result of image processing filter as new image.</remarks>
        ///
        /// <exception cref="UnsupportedImageFormatException">Unsupported pixel format of the source image.</exception>
        ///
        public UnmanagedImage Apply(UnmanagedImage image)
        {
            var destImage = errosion.Apply(image);

            dilatation.ApplyInPlace(destImage);

            return(destImage);
        }
Esempio n. 3
0
        /// <summary>
        /// Filter the image froma HSV colour range
        /// </summary>
        /// <param name="image">Bitmap Image, any suitable image</param>
        /// <returns>Bitmap Image</returns>
        public Bitmap addFilters(Bitmap image)
        {
			//Instantiate new HSL filter 
            AForge.Imaging.Filters.HSLFiltering hslFilter = new AForge.Imaging.Filters.HSLFiltering();
			
			//Define HSL colour range (default colour is orange)
            hslFilter.Hue = new AForge.IntRange(0, 50);
            hslFilter.Saturation = new AForge.DoubleRange(0.7, 1);
            hslFilter.Luminance = new AForge.DoubleRange(0.2, 0.7);

	    //Instantiate new RGB filter 
            /*AForge.Imaging.Filters.ColorFiltering rgbFilter = new AForge.Imaging.Filters.ColorFiltering();
			
	    //Define RGB colour range (default colour is orange)
            rgbFilter.Red = new AForge.IntRange(60, 180);
            rgbFilter.Green = new AForge.IntRange(10, 80);
            rgbFilter.Blue = new AForge.IntRange(5, 25);*/

	    //Apply the HSL filter to the input image
            hslFilter.ApplyInPlace(image);
			
	    //Create a 5 by 5 matrix using a short array
            int rows = 5;
            int cols = 5;
            short[,] Matrix = new short[rows, cols];

            for (int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    Matrix[i, j] = 1;
			
			//Instantiate new dilate filter with the 5 by 5 matrix
			AForge.Imaging.Filters.Dilatation dilate = new AForge.Imaging.Filters.Dilatation(Matrix);
			//Apply the filter
			dilate.ApplyInPlace(image);

            return image;
        }
Esempio n. 4
0
        // 선 가늘게
        public static Bitmap thin(Bitmap source)
        {
            ///////////// 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();

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

            return source;
        }
Esempio n. 5
0
 public void ApplyInPlace(Bitmap image)
 {
     dilatation.ApplyInPlace(image);
     errosion.ApplyInPlace(image);
 }
Esempio n. 6
0
        // 선 가늘게
        private void button36_Click(object sender, EventArgs e)
        {
            ///////////// 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 파일 경로
            DocumentAnalysis.IniUtil ini = new DocumentAnalysis.IniUtil(filePath);   // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

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

            Dilatation filter = new Dilatation();
            filter.ApplyInPlace(source);

            Global.source = source;
            pictureBox1.Image = Global.source;
            pictureBox1.Invalidate();

            textBox25.Text = (int.Parse(textBox25.Text) + 1).ToString();
            ini.SetIniValue("선굵기값", "가늘게횟수", textBox25.Text.ToString());

            //string path = calculator.CreateFileCheck("C:\\Program Files\\PLOCR\\prescription.png");
            //pictureBox1.Image.Save(path);
        }