Esempio n. 1
0
        private void button13_Click(object sender, EventArgs e)
        {
            try
            {
                DirectoryInfo DirNew = new DirectoryInfo(Application.StartupPath + "\\" + textBMPFolders.Text + "\\BMPFolders");
                if (!DirNew.Exists)
                {
                    DirNew.Create();
                }

                DirectoryInfo Dir = new DirectoryInfo(Application.StartupPath + "\\" + textBMPFolders.Text);

                foreach (FileInfo f in Dir.GetFiles("*.bmp"))
                {
                    textToPath.Text = textBMPFolders.Text + "\\" + f.Name;

                    //ANNWrapper.BlackWhiteBMP(Application.StartupPath + "\\" + textToPath.Text, Int32.Parse(textInputInt.Text));

                    IntPtr hdibHandle = ANNWrapper.ReadDIBFile(Application.StartupPath + "\\" + textToPath.Text);

                    ANNWrapper.Convert256toGray(hdibHandle);

                    //ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\Convert256toGray.bmp");

                    ANNWrapper.ConvertGrayToWhiteBlack(hdibHandle);

                    //ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\ConvertGrayToWhiteBlack.bmp");

                    ////ANNWrapper.GradientSharp(hdibHandle);
                    ANNWrapper.RemoveScatterNoise(hdibHandle);

                    //ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\RemoveScatterNoise.bmp");

                    //ANNWrapper.SlopeAdjust(hdibHandle);

                    Int32 charRectID = ANNWrapper.CharSegment(hdibHandle);

                    if (charRectID >= 0)
                    {
                        IntPtr newHdibHandle = ANNWrapper.AutoAlign(hdibHandle, charRectID);
                        ANNWrapper.SaveDIB(newHdibHandle, Application.StartupPath + "\\AutoAlign.bmp");
                        ANNWrapper.SaveSegment(newHdibHandle, charRectID, Application.StartupPath + "\\" + textBMPFolders.Text + "\\BMPFolders");
                        ANNWrapper.ReleaseDIBFile(newHdibHandle);
                    }
                    else
                    {
                        MessageBox.Show("CharSegment Step Failure !");
                    }

                    ANNWrapper.ReleaseDIBFile(hdibHandle);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(textToPath.Text);
            }
        }
Esempio n. 2
0
        private void button9_Click(object sender, EventArgs e)
        {
            DirectoryInfo Dir = new DirectoryInfo(Application.StartupPath + "\\");

            foreach (FileInfo f in Dir.GetFiles("*Capture.bmp"))
            {
                try
                {
                    textToPath.Text = f.Name;

                    IntPtr hdibHandle = ANNWrapper.ReadDIBFile(Application.StartupPath + "\\" + textToPath.Text);

                    ANNWrapper.Convert256toGray(hdibHandle);

                    ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\Convert256toGray.bmp");

                    ANNWrapper.ConvertGrayToWhiteBlack(hdibHandle);

                    ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\ConvertGrayToWhiteBlack.bmp");

                    //ANNWrapper.GradientSharp(hdibHandle);
                    ANNWrapper.RemoveScatterNoise(hdibHandle);

                    ANNWrapper.SaveDIB(hdibHandle, Application.StartupPath + "\\RemoveScatterNoise.bmp");

                    //ANNWrapper.SlopeAdjust(hdibHandle);

                    Int32 charRectID = ANNWrapper.CharSegment(hdibHandle);

                    if (charRectID >= 0)
                    {
                        //ANNWrapper.StdDIBbyRect(hdibHandle, charRectID, 16, 16);
                        IntPtr newHdibHandle = ANNWrapper.AutoAlign(hdibHandle, charRectID);
                        ANNWrapper.SaveSegment(newHdibHandle, charRectID, Application.StartupPath + "\\");
                        ANNWrapper.ReleaseDIBFile(newHdibHandle);
                    }
                    else
                    {
                        MessageBox.Show("CharSegment Step False");
                    }

                    ANNWrapper.ReleaseDIBFile(hdibHandle);
                }
                catch (Exception exp)
                {
                    MessageBox.Show(textToPath.Text);
                }
            }
        }