├── .gitignore
├── ImageLibrary
├── Class1.cs
├── Gray.cs
├── ImageLibrary.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Util.cs
├── README
├── graph.sln
├── graph
├── App.config
├── Form1.Designer.vb
├── Form1.resx
├── Form1.vb
├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
└── graph.vbproj
├── graph_cs
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── graph_cs.csproj
├── libtesseract302.dll
├── pic
├── 2013101809463539011.jpg
├── plugin (1).jpg
├── plugin (2).jpg
├── plugin (3).jpg
├── plugin (4).jpg
├── plugin (5).jpg
├── plugin (6).jpg
├── plugin (7).jpg
└── plugin.jpg
├── tesseract-ocr-3.02.chi_sim.tar.gz
└── tesseract-ocr-3.02.eng.tar.gz
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19 | !packages/*/build/
20 |
21 | # MSTest test Results
22 | [Tt]est[Rr]esult*/
23 | [Bb]uild[Ll]og.*
24 |
25 | *_i.c
26 | *_p.c
27 | *.ilk
28 | *.meta
29 | *.obj
30 | *.pch
31 | *.pdb
32 | *.pgc
33 | *.pgd
34 | *.rsp
35 | *.sbr
36 | *.tlb
37 | *.tli
38 | *.tlh
39 | *.tmp
40 | *.tmp_proj
41 | *.log
42 | *.vspscc
43 | *.vssscc
44 | .builds
45 | *.pidb
46 | *.log
47 | *.scc
48 |
49 | # Visual C++ cache files
50 | ipch/
51 | *.aps
52 | *.ncb
53 | *.opensdf
54 | *.sdf
55 | *.cachefile
56 |
57 | # Visual Studio profiler
58 | *.psess
59 | *.vsp
60 | *.vspx
61 |
62 | # Guidance Automation Toolkit
63 | *.gpState
64 |
65 | # ReSharper is a .NET coding add-in
66 | _ReSharper*/
67 | *.[Rr]e[Ss]harper
68 |
69 | # TeamCity is a build add-in
70 | _TeamCity*
71 |
72 | # DotCover is a Code Coverage Tool
73 | *.dotCover
74 |
75 | # NCrunch
76 | *.ncrunch*
77 | .*crunch*.local.xml
78 |
79 | # Installshield output folder
80 | [Ee]xpress/
81 |
82 | # DocProject is a documentation generator add-in
83 | DocProject/buildhelp/
84 | DocProject/Help/*.HxT
85 | DocProject/Help/*.HxC
86 | DocProject/Help/*.hhc
87 | DocProject/Help/*.hhk
88 | DocProject/Help/*.hhp
89 | DocProject/Help/Html2
90 | DocProject/Help/html
91 |
92 | # Click-Once directory
93 | publish/
94 |
95 | # Publish Web Output
96 | *.Publish.xml
97 | *.pubxml
98 |
99 | # NuGet Packages Directory
100 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
101 | #packages/
102 |
103 | # Windows Azure Build Output
104 | csx
105 | *.build.csdef
106 |
107 | # Windows Store app package directory
108 | AppPackages/
109 |
110 | # Others
111 | sql/
112 | *.Cache
113 | ClientBin/
114 | [Ss]tyle[Cc]op.*
115 | ~$*
116 | *~
117 | *.dbmdl
118 | *.[Pp]ublish.xml
119 | *.pfx
120 | *.publishsettings
121 |
122 | # RIA/Silverlight projects
123 | Generated_Code/
124 |
125 | # Backup & report files from converting an old project file to a newer
126 | # Visual Studio version. Backup files are not needed, because we have git ;-)
127 | _UpgradeReport_Files/
128 | Backup*/
129 | UpgradeLog*.XML
130 | UpgradeLog*.htm
131 |
132 | # SQL Server files
133 | App_Data/*.mdf
134 | App_Data/*.ldf
135 |
136 | # =========================
137 | # Windows detritus
138 | # =========================
139 |
140 | # Windows image file caches
141 | Thumbs.db
142 | ehthumbs.db
143 |
144 | # Folder config file
145 | Desktop.ini
146 |
147 | # Recycle Bin used on file shares
148 | $RECYCLE.BIN/
149 |
150 | # Mac crap
151 | .DS_Store
152 | .idea
--------------------------------------------------------------------------------
/ImageLibrary/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | using System.Text;
5 |
6 |
7 | namespace ImageLibrary
8 | {
9 | public class Class1
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ImageLibrary/Gray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 |
5 | using System.Text;
6 |
7 |
8 | namespace ImageLibrary
9 | {
10 | public class Gray
11 | {
12 | ///
13 | /// 图像灰度化
14 | ///
15 | /// 图片
16 | /// 1,平均值 2,YUC 3,最小值
17 | ///
18 | public static Bitmap GrayScale(Bitmap srcImage, int m)
19 | {
20 | var image = srcImage;
21 | int width = image.Width - 1;
22 | int height = image.Height - 1;
23 |
24 | Color color;
25 | for (int i = width; i >= 0; i--)
26 | {
27 | for (int j = height; j >= 0; j--)
28 | {
29 | int gray;
30 | //读取每一个像素
31 | color = image.GetPixel(i, j); //计算灰度值
32 | if (m == 1)
33 | {
34 | gray = (int)((color.R+ color.G + color.B)/3 );
35 | }
36 | if (m == 2)
37 | {
38 | gray = (int)(color.B * 0.3 + color.G * 0.59 + color.R * 0.11);
39 | }
40 | else
41 | {
42 | gray = (int)(Math.Min(Math.Min(color.R, color.G), color.B));
43 | }
44 |
45 | //int gray = (color.R + color.G + color.B) / 3;
46 | Color colorResult = Color.FromArgb(255, gray, gray, gray);
47 | //设置像素为灰度
48 | image.SetPixel(i, j, colorResult);
49 | }
50 | }
51 | return image;
52 | }
53 | ///
54 | /// 生成灰度直方图(范围为0-255)
55 | ///
56 | /// 灰度化之后的图像
57 | ///
58 | public static int[] GrayScaleHistogram(Bitmap srcImage)
59 | {
60 | int[] histogram=new int[256];
61 | var image = srcImage;
62 | int width = image.Width - 1;
63 | int height = image.Height - 1;
64 |
65 | Color color;
66 | for (int i = width; i >= 0; i--)
67 | {
68 | for (int j = height; j >= 0; j--)
69 | {
70 |
71 | color = image.GetPixel(i, j); //计算灰度值
72 | histogram[color.R]++;
73 |
74 | }
75 | }
76 | return histogram;
77 |
78 | }
79 | ///
80 | /// 二值化
81 | ///
82 | ///
83 | /// 阈值
84 | ///
85 | public static Bitmap BinaryZation(Bitmap srcImage, int threshold)
86 | {
87 | var image = srcImage;
88 | int width = image.Width - 1;
89 | int height = image.Height - 1;
90 |
91 | Color color;
92 | for (int i = width; i >= 0; i--)
93 | {
94 | for (int j = height; j >= 0; j--)
95 | {
96 |
97 | color = image.GetPixel(i, j); //计算灰度值
98 | Color colorResult;
99 | if (color.R > threshold)
100 | {
101 | colorResult = Color.FromArgb(255, 255, 255);
102 | }
103 | else
104 | {
105 | colorResult = Color.FromArgb(0, 0, 0);
106 | }
107 | //设置像素为灰度
108 | image.SetPixel(i, j, colorResult);
109 | }
110 | }
111 | return image;
112 | }
113 | ///
114 | /// 中值滤波降噪
115 | ///
116 | ///
117 | ///
118 | public static Bitmap NoiseReduction(Bitmap srcImage)
119 | {
120 | var image = srcImage;
121 | int width = image.Width - 1;
122 | int height = image.Height - 1;
123 | int count = 0;
124 | Color color;
125 | for (int i = 0; i 0 && j > 0)
133 | {
134 | try
135 | {
136 | count = image.GetPixel(i - 1, j - 1).R + image.GetPixel(i, j - 1).R +
137 | image.GetPixel(i + 1, j - 1).R
138 | + image.GetPixel(i - 1, j).R + image.GetPixel(i + 1, j).R
139 | + image.GetPixel(i - 1, j + 1).R + image.GetPixel(i, j + 1).R +
140 | image.GetPixel(i + 1, j + 1).R;
141 | }
142 | catch (Exception)
143 | {
144 |
145 | }
146 |
147 | if (count == 2040)
148 | {
149 | colorResult = Color.FromArgb(255, 255, 255);
150 | image.SetPixel(i, j, colorResult);
151 | }
152 | }
153 | //设置像素为灰度
154 |
155 | }
156 | }
157 | return image;
158 | }
159 | ///
160 | /// 生成文字图形(srcImage必须为二值化后的图像)
161 | ///
162 | ///
163 | ///
164 | public static int[,] PixelImage(Bitmap srcImage)
165 | {
166 | var image = srcImage;
167 | int width = image.Width - 1;
168 | int height = image.Height - 1;
169 | StringBuilder stringBuilder = new StringBuilder();
170 | Color color;
171 | var imagearray = new int[height,width];
172 |
173 | for (int i = 0; i < height; i++)
174 | {
175 | for (int j =0;j< width; j++)
176 | {
177 |
178 | color = image.GetPixel(j,i); //计算灰度值
179 |
180 | //设置像素为灰度
181 | var v = color.R == 255 ? 1 : 0;
182 | stringBuilder.Append(v);
183 | imagearray[i, j] = v;
184 | }
185 | stringBuilder.Append("\r");
186 | }
187 | return imagearray;
188 |
189 | }
190 |
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/ImageLibrary/ImageLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {86926EC7-C866-4E4E-A43E-A9E70FA2DD18}
8 | Library
9 | Properties
10 | ImageLibrary
11 | ImageLibrary
12 | v2.0
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
57 |
--------------------------------------------------------------------------------
/ImageLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ImageLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("ImageLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a57dab14-2782-4bdb-a717-0ad1f6075d46")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ImageLibrary/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ImageLibrary
6 | {
7 | public class Util
8 | {
9 | ///
10 | /// 把像素数组转为像素的字符串(可视化字符串)
11 | ///
12 | ///
13 | ///
14 | public static string EachArrayToString(int[,] resultArray)
15 | {
16 | StringBuilder result=new StringBuilder( );
17 | var h = resultArray.GetLength(0);
18 | var w = resultArray.GetLength(1);
19 | for (var i = 0; i < h; i++)
20 | {
21 | for (int j = 0; j < w; j++)
22 | {
23 | result.Append(resultArray[i, j]);
24 | }
25 | result.Append("\r");
26 | }
27 | return result.ToString();
28 | }
29 |
30 |
31 | public static string GetValidRegion(int[,] resultArray)
32 | {
33 | StringBuilder result = new StringBuilder();
34 | var h = resultArray.GetLength(0);
35 | var w = resultArray.GetLength(1);
36 | for (var i = 0; i < h; i++)
37 | {
38 | for (int j = 0; j < w; j++)
39 | {
40 | result.Append(resultArray[i, j]);
41 | }
42 | result.Append("\r");
43 | }
44 | return result.ToString();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | This file was created by JetBrains WebStorm 6.0 for binding GitHub repository
--------------------------------------------------------------------------------
/graph.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "graph", "graph\graph.vbproj", "{257017E4-3440-47BB-8F5F-CD83F29DC954}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "graph_cs", "graph_cs\graph_cs.csproj", "{79FE52C8-8885-4177-9BE6-4E8726E9EFAC}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageLibrary", "ImageLibrary\ImageLibrary.csproj", "{86926EC7-C866-4E4E-A43E-A9E70FA2DD18}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {257017E4-3440-47BB-8F5F-CD83F29DC954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {257017E4-3440-47BB-8F5F-CD83F29DC954}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {257017E4-3440-47BB-8F5F-CD83F29DC954}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {257017E4-3440-47BB-8F5F-CD83F29DC954}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {79FE52C8-8885-4177-9BE6-4E8726E9EFAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {79FE52C8-8885-4177-9BE6-4E8726E9EFAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {79FE52C8-8885-4177-9BE6-4E8726E9EFAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {79FE52C8-8885-4177-9BE6-4E8726E9EFAC}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {86926EC7-C866-4E4E-A43E-A9E70FA2DD18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {86926EC7-C866-4E4E-A43E-A9E70FA2DD18}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {86926EC7-C866-4E4E-A43E-A9E70FA2DD18}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {86926EC7-C866-4E4E-A43E-A9E70FA2DD18}.Release|Any CPU.Build.0 = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(SolutionProperties) = preSolution
30 | HideSolutionNode = FALSE
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/graph/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/graph/Form1.Designer.vb:
--------------------------------------------------------------------------------
1 | _
2 | Partial Class Form1
3 | Inherits System.Windows.Forms.Form
4 |
5 | 'Form 重写 Dispose,以清理组件列表。
6 | _
7 | Protected Overrides Sub Dispose(ByVal disposing As Boolean)
8 | Try
9 | If disposing AndAlso components IsNot Nothing Then
10 | components.Dispose()
11 | End If
12 | Finally
13 | MyBase.Dispose(disposing)
14 | End Try
15 | End Sub
16 |
17 | 'Windows 窗体设计器所必需的
18 | Private components As System.ComponentModel.IContainer
19 |
20 | '注意: 以下过程是 Windows 窗体设计器所必需的
21 | '可以使用 Windows 窗体设计器修改它。
22 | '不要使用代码编辑器修改它。
23 | _
24 | Private Sub InitializeComponent()
25 | Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
26 | Me.Btn_OpenImage = New System.Windows.Forms.Button()
27 | Me.SuspendLayout()
28 | '
29 | 'OpenFileDialog1
30 | '
31 | Me.OpenFileDialog1.FileName = "OpenFileDialog1"
32 | '
33 | 'Btn_OpenImage
34 | '
35 | Me.Btn_OpenImage.Location = New System.Drawing.Point(38, 32)
36 | Me.Btn_OpenImage.Name = "Btn_OpenImage"
37 | Me.Btn_OpenImage.Size = New System.Drawing.Size(75, 23)
38 | Me.Btn_OpenImage.TabIndex = 0
39 | Me.Btn_OpenImage.Text = "Open Image"
40 | Me.Btn_OpenImage.UseVisualStyleBackColor = True
41 | '
42 | 'Form1
43 | '
44 | Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
45 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
46 | Me.ClientSize = New System.Drawing.Size(1198, 577)
47 | Me.Controls.Add(Me.Btn_OpenImage)
48 | Me.Name = "Form1"
49 | Me.Text = "Form1"
50 | Me.ResumeLayout(False)
51 |
52 | End Sub
53 | Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
54 | Friend WithEvents Btn_OpenImage As System.Windows.Forms.Button
55 |
56 | End Class
57 |
--------------------------------------------------------------------------------
/graph/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/graph/Form1.vb:
--------------------------------------------------------------------------------
1 | Public Class Form1
2 |
3 | Private Sub Btn_OpenImage_Click(sender As Object, e As EventArgs) Handles Btn_OpenImage.Click
4 |
5 | End Sub
6 | End Class
7 |
--------------------------------------------------------------------------------
/graph/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.18408
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
18 | ' or if you encounter build errors in this file, go to the Project Designer
19 | ' (go to Project Properties or double-click the My Project node in
20 | ' Solution Explorer), and make changes on the Application tab.
21 | '
22 | Partial Friend Class MyApplication
23 |
24 | _
25 | Public Sub New()
26 | MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
27 | Me.IsSingleInstance = false
28 | Me.EnableVisualStyles = true
29 | Me.SaveMySettingsOnExit = true
30 | Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
31 | End Sub
32 |
33 | _
34 | Protected Overrides Sub OnCreateMainForm()
35 | Me.MainForm = Global.graph.Form1
36 | End Sub
37 | End Class
38 | End Namespace
39 |
--------------------------------------------------------------------------------
/graph/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | Form1
5 | false
6 | 0
7 | true
8 | 0
9 | 0
10 | true
11 |
12 |
--------------------------------------------------------------------------------
/graph/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' 有关程序集的常规信息通过下列特性集
6 | ' 控制。更改这些特性值可修改
7 | ' 与程序集关联的信息。
8 |
9 | ' 查看程序集特性的值
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | '如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
21 |
22 |
23 | ' 程序集的版本信息由下面四个值组成:
24 | '
25 | ' 主版本
26 | ' 次版本
27 | ' 生成号
28 | ' 修订号
29 | '
30 | ' 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
31 | ' 方法是按如下所示使用“*”:
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/graph/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.18408
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My.Resources
16 |
17 | 'This class was auto-generated by the StronglyTypedResourceBuilder
18 | 'class via a tool like ResGen or Visual Studio.
19 | 'To add or remove a member, edit your .ResX file then rerun ResGen
20 | 'with the /str option, or rebuild your VS project.
21 | '''
22 | ''' A strongly-typed resource class, for looking up localized strings, etc.
23 | '''
24 | _
28 | Friend Module Resources
29 |
30 | Private resourceMan As Global.System.Resources.ResourceManager
31 |
32 | Private resourceCulture As Global.System.Globalization.CultureInfo
33 |
34 | '''
35 | ''' Returns the cached ResourceManager instance used by this class.
36 | '''
37 | _
38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
39 | Get
40 | If Object.ReferenceEquals(resourceMan, Nothing) Then
41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("graph.Resources", GetType(Resources).Assembly)
42 | resourceMan = temp
43 | End If
44 | Return resourceMan
45 | End Get
46 | End Property
47 |
48 | '''
49 | ''' Overrides the current thread's CurrentUICulture property for all
50 | ''' resource lookups using this strongly typed resource class.
51 | '''
52 | _
53 | Friend Property Culture() As Global.System.Globalization.CultureInfo
54 | Get
55 | Return resourceCulture
56 | End Get
57 | Set(ByVal value As Global.System.Globalization.CultureInfo)
58 | resourceCulture = value
59 | End Set
60 | End Property
61 | End Module
62 | End Namespace
63 |
--------------------------------------------------------------------------------
/graph/My Project/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/graph/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.18408
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
24 |
25 | #Region "My.Settings Auto-Save Functionality"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.graph.My.MySettings
68 | Get
69 | Return Global.graph.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/graph/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/graph/graph.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {257017E4-3440-47BB-8F5F-CD83F29DC954}
8 | WinExe
9 | graph.My.MyApplication
10 | graph
11 | graph
12 | 512
13 | WindowsForms
14 | v4.5
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | true
21 | true
22 | bin\Debug\
23 | graph.xml
24 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | false
30 | true
31 | true
32 | bin\Release\
33 | graph.xml
34 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
35 |
36 |
37 | On
38 |
39 |
40 | Binary
41 |
42 |
43 | Off
44 |
45 |
46 | On
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Form
75 |
76 |
77 | Form1.vb
78 | Form
79 |
80 |
81 |
82 | True
83 | Application.myapp
84 |
85 |
86 | True
87 | True
88 | Resources.resx
89 |
90 |
91 | True
92 | Settings.settings
93 | True
94 |
95 |
96 |
97 |
98 | Form1.vb
99 |
100 |
101 | VbMyResourcesResXFileCodeGenerator
102 | Resources.Designer.vb
103 | My.Resources
104 | Designer
105 |
106 |
107 |
108 |
109 | MyApplicationCodeGenerator
110 | Application.Designer.vb
111 |
112 |
113 | SettingsSingleFileGenerator
114 | My
115 | Settings.Designer.vb
116 |
117 |
118 |
119 |
120 |
127 |
--------------------------------------------------------------------------------
/graph_cs/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/graph_cs/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace graph_cs
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
32 | this.btn_OpenImage = new System.Windows.Forms.Button();
33 | this.befor_pic = new System.Windows.Forms.PictureBox();
34 | this.after_pic = new System.Windows.Forms.PictureBox();
35 | this.btn_ImageGray1 = new System.Windows.Forms.Button();
36 | this.btn_ImageGray2 = new System.Windows.Forms.Button();
37 | this.btn_ImageGray3 = new System.Windows.Forms.Button();
38 | this.btn_binary = new System.Windows.Forms.Button();
39 | this.txtthreshold = new System.Windows.Forms.TextBox();
40 | this.label1 = new System.Windows.Forms.Label();
41 | this.btn_start = new System.Windows.Forms.Button();
42 | this.label2 = new System.Windows.Forms.Label();
43 | this.richTextBox1 = new System.Windows.Forms.RichTextBox();
44 | this.btn_pixelImage = new System.Windows.Forms.Button();
45 | this.btn_cut = new System.Windows.Forms.Button();
46 | this.btn_histogram = new System.Windows.Forms.Button();
47 | this.pic_histogram = new System.Windows.Forms.PictureBox();
48 | this.btn_denoise = new System.Windows.Forms.Button();
49 | ((System.ComponentModel.ISupportInitialize)(this.befor_pic)).BeginInit();
50 | ((System.ComponentModel.ISupportInitialize)(this.after_pic)).BeginInit();
51 | ((System.ComponentModel.ISupportInitialize)(this.pic_histogram)).BeginInit();
52 | this.SuspendLayout();
53 | //
54 | // openFileDialog1
55 | //
56 | this.openFileDialog1.FileName = "openFileDialog1";
57 | this.openFileDialog1.Filter = "图片文件(*.jpg,*.bmp,*.png)|*.jpg;*.bmp";
58 | //
59 | // btn_OpenImage
60 | //
61 | this.btn_OpenImage.Location = new System.Drawing.Point(25, 35);
62 | this.btn_OpenImage.Name = "btn_OpenImage";
63 | this.btn_OpenImage.Size = new System.Drawing.Size(75, 23);
64 | this.btn_OpenImage.TabIndex = 0;
65 | this.btn_OpenImage.Text = "Open Image";
66 | this.btn_OpenImage.UseVisualStyleBackColor = true;
67 | this.btn_OpenImage.Click += new System.EventHandler(this.btn_OpenImage_Click);
68 | //
69 | // befor_pic
70 | //
71 | this.befor_pic.Location = new System.Drawing.Point(121, 21);
72 | this.befor_pic.Name = "befor_pic";
73 | this.befor_pic.Size = new System.Drawing.Size(298, 146);
74 | this.befor_pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
75 | this.befor_pic.TabIndex = 1;
76 | this.befor_pic.TabStop = false;
77 | //
78 | // after_pic
79 | //
80 | this.after_pic.Location = new System.Drawing.Point(500, 21);
81 | this.after_pic.Name = "after_pic";
82 | this.after_pic.Size = new System.Drawing.Size(266, 146);
83 | this.after_pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
84 | this.after_pic.TabIndex = 2;
85 | this.after_pic.TabStop = false;
86 | //
87 | // btn_ImageGray1
88 | //
89 | this.btn_ImageGray1.Location = new System.Drawing.Point(25, 65);
90 | this.btn_ImageGray1.Name = "btn_ImageGray1";
91 | this.btn_ImageGray1.Size = new System.Drawing.Size(75, 23);
92 | this.btn_ImageGray1.TabIndex = 3;
93 | this.btn_ImageGray1.Text = "YUV变灰";
94 | this.btn_ImageGray1.UseVisualStyleBackColor = true;
95 | this.btn_ImageGray1.Click += new System.EventHandler(this.btn_ImageGray_Click);
96 | //
97 | // btn_ImageGray2
98 | //
99 | this.btn_ImageGray2.Location = new System.Drawing.Point(25, 95);
100 | this.btn_ImageGray2.Name = "btn_ImageGray2";
101 | this.btn_ImageGray2.Size = new System.Drawing.Size(90, 23);
102 | this.btn_ImageGray2.TabIndex = 4;
103 | this.btn_ImageGray2.Text = "取平均值变灰";
104 | this.btn_ImageGray2.UseVisualStyleBackColor = true;
105 | this.btn_ImageGray2.Click += new System.EventHandler(this.btn_ImageGray2_Click);
106 | //
107 | // btn_ImageGray3
108 | //
109 | this.btn_ImageGray3.Location = new System.Drawing.Point(25, 125);
110 | this.btn_ImageGray3.Name = "btn_ImageGray3";
111 | this.btn_ImageGray3.Size = new System.Drawing.Size(90, 23);
112 | this.btn_ImageGray3.TabIndex = 5;
113 | this.btn_ImageGray3.Text = "取最小值变灰";
114 | this.btn_ImageGray3.UseVisualStyleBackColor = true;
115 | this.btn_ImageGray3.Click += new System.EventHandler(this.btn_ImageGray3_Click);
116 | //
117 | // btn_binary
118 | //
119 | this.btn_binary.Location = new System.Drawing.Point(25, 196);
120 | this.btn_binary.Name = "btn_binary";
121 | this.btn_binary.Size = new System.Drawing.Size(75, 23);
122 | this.btn_binary.TabIndex = 6;
123 | this.btn_binary.Text = "二值化";
124 | this.btn_binary.UseVisualStyleBackColor = true;
125 | this.btn_binary.Click += new System.EventHandler(this.btn_binary_Click);
126 | //
127 | // txtthreshold
128 | //
129 | this.txtthreshold.Location = new System.Drawing.Point(61, 223);
130 | this.txtthreshold.Name = "txtthreshold";
131 | this.txtthreshold.Size = new System.Drawing.Size(39, 21);
132 | this.txtthreshold.TabIndex = 7;
133 | this.txtthreshold.Text = "127";
134 | //
135 | // label1
136 | //
137 | this.label1.AutoSize = true;
138 | this.label1.Location = new System.Drawing.Point(23, 226);
139 | this.label1.Name = "label1";
140 | this.label1.Size = new System.Drawing.Size(41, 12);
141 | this.label1.TabIndex = 8;
142 | this.label1.Text = "阈值:";
143 | //
144 | // btn_start
145 | //
146 | this.btn_start.Location = new System.Drawing.Point(25, 461);
147 | this.btn_start.Name = "btn_start";
148 | this.btn_start.Size = new System.Drawing.Size(75, 23);
149 | this.btn_start.TabIndex = 9;
150 | this.btn_start.Text = "识别";
151 | this.btn_start.UseVisualStyleBackColor = true;
152 | //
153 | // label2
154 | //
155 | this.label2.AutoSize = true;
156 | this.label2.Location = new System.Drawing.Point(23, 487);
157 | this.label2.Name = "label2";
158 | this.label2.Size = new System.Drawing.Size(41, 12);
159 | this.label2.TabIndex = 10;
160 | this.label2.Text = "label2";
161 | //
162 | // richTextBox1
163 | //
164 | this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
165 | | System.Windows.Forms.AnchorStyles.Left)
166 | | System.Windows.Forms.AnchorStyles.Right)));
167 | this.richTextBox1.Location = new System.Drawing.Point(121, 284);
168 | this.richTextBox1.Name = "richTextBox1";
169 | this.richTextBox1.Size = new System.Drawing.Size(1077, 331);
170 | this.richTextBox1.TabIndex = 11;
171 | this.richTextBox1.Text = "";
172 | //
173 | // btn_pixelImage
174 | //
175 | this.btn_pixelImage.Location = new System.Drawing.Point(25, 349);
176 | this.btn_pixelImage.Name = "btn_pixelImage";
177 | this.btn_pixelImage.Size = new System.Drawing.Size(75, 21);
178 | this.btn_pixelImage.TabIndex = 12;
179 | this.btn_pixelImage.Text = "生成像素图";
180 | this.btn_pixelImage.UseVisualStyleBackColor = true;
181 | this.btn_pixelImage.Click += new System.EventHandler(this.btn_pixelImage_Click);
182 | //
183 | // btn_cut
184 | //
185 | this.btn_cut.Location = new System.Drawing.Point(25, 386);
186 | this.btn_cut.Name = "btn_cut";
187 | this.btn_cut.Size = new System.Drawing.Size(90, 23);
188 | this.btn_cut.TabIndex = 13;
189 | this.btn_cut.Text = "截取内容区域";
190 | this.btn_cut.UseVisualStyleBackColor = true;
191 | this.btn_cut.Click += new System.EventHandler(this.btn_cut_Click);
192 | //
193 | // btn_histogram
194 | //
195 | this.btn_histogram.Location = new System.Drawing.Point(25, 155);
196 | this.btn_histogram.Name = "btn_histogram";
197 | this.btn_histogram.Size = new System.Drawing.Size(75, 23);
198 | this.btn_histogram.TabIndex = 14;
199 | this.btn_histogram.Text = "直方图";
200 | this.btn_histogram.UseVisualStyleBackColor = true;
201 | this.btn_histogram.Click += new System.EventHandler(this.btn_histogram_Click);
202 | //
203 | // pic_histogram
204 | //
205 | this.pic_histogram.Location = new System.Drawing.Point(800, 21);
206 | this.pic_histogram.Name = "pic_histogram";
207 | this.pic_histogram.Size = new System.Drawing.Size(410, 257);
208 | this.pic_histogram.TabIndex = 15;
209 | this.pic_histogram.TabStop = false;
210 | //
211 | // btn_denoise
212 | //
213 | this.btn_denoise.Location = new System.Drawing.Point(25, 255);
214 | this.btn_denoise.Name = "btn_denoise";
215 | this.btn_denoise.Size = new System.Drawing.Size(75, 23);
216 | this.btn_denoise.TabIndex = 16;
217 | this.btn_denoise.Text = "降噪";
218 | this.btn_denoise.UseVisualStyleBackColor = true;
219 | this.btn_denoise.Click += new System.EventHandler(this.btn_denoise_Click);
220 | //
221 | // Form1
222 | //
223 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
224 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
225 | this.ClientSize = new System.Drawing.Size(1210, 626);
226 | this.Controls.Add(this.btn_denoise);
227 | this.Controls.Add(this.pic_histogram);
228 | this.Controls.Add(this.btn_histogram);
229 | this.Controls.Add(this.btn_cut);
230 | this.Controls.Add(this.btn_pixelImage);
231 | this.Controls.Add(this.richTextBox1);
232 | this.Controls.Add(this.label2);
233 | this.Controls.Add(this.btn_start);
234 | this.Controls.Add(this.label1);
235 | this.Controls.Add(this.txtthreshold);
236 | this.Controls.Add(this.btn_binary);
237 | this.Controls.Add(this.btn_ImageGray3);
238 | this.Controls.Add(this.btn_ImageGray2);
239 | this.Controls.Add(this.btn_ImageGray1);
240 | this.Controls.Add(this.after_pic);
241 | this.Controls.Add(this.befor_pic);
242 | this.Controls.Add(this.btn_OpenImage);
243 | this.Name = "Form1";
244 | this.Text = "Form1";
245 | ((System.ComponentModel.ISupportInitialize)(this.befor_pic)).EndInit();
246 | ((System.ComponentModel.ISupportInitialize)(this.after_pic)).EndInit();
247 | ((System.ComponentModel.ISupportInitialize)(this.pic_histogram)).EndInit();
248 | this.ResumeLayout(false);
249 | this.PerformLayout();
250 |
251 | }
252 |
253 | #endregion
254 |
255 | private System.Windows.Forms.OpenFileDialog openFileDialog1;
256 | private System.Windows.Forms.Button btn_OpenImage;
257 | private System.Windows.Forms.PictureBox befor_pic;
258 | private System.Windows.Forms.PictureBox after_pic;
259 | private System.Windows.Forms.Button btn_ImageGray1;
260 | private System.Windows.Forms.Button btn_ImageGray2;
261 | private System.Windows.Forms.Button btn_ImageGray3;
262 | private System.Windows.Forms.Button btn_binary;
263 | private System.Windows.Forms.TextBox txtthreshold;
264 | private System.Windows.Forms.Label label1;
265 | private System.Windows.Forms.Button btn_start;
266 | private System.Windows.Forms.Label label2;
267 | private System.Windows.Forms.RichTextBox richTextBox1;
268 | private System.Windows.Forms.Button btn_pixelImage;
269 | private System.Windows.Forms.Button btn_cut;
270 | private System.Windows.Forms.Button btn_histogram;
271 | private System.Windows.Forms.PictureBox pic_histogram;
272 | private System.Windows.Forms.Button btn_denoise;
273 | }
274 | }
275 |
276 |
--------------------------------------------------------------------------------
/graph_cs/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Drawing.Drawing2D;
7 | using System.IO;
8 |
9 | using System.Text;
10 |
11 | using System.Windows.Forms;
12 | using ImageLibrary;
13 | namespace graph_cs
14 | {
15 | public partial class Form1 : Form
16 | {
17 | public Form1()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | private string ImagePath;
23 | private void btn_OpenImage_Click(object sender, EventArgs e)
24 | {
25 | if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
26 | {
27 | ImagePath = openFileDialog1.FileName;
28 |
29 | ViewImage();
30 | }
31 |
32 | }
33 | private void ViewImage()
34 | {
35 | Image img = Image.FromFile(ImagePath);
36 | Bitmap bitmap = new Bitmap(img);
37 | befor_pic.Image = bitmap;
38 | }
39 |
40 |
41 | private void btn_ImageGray_Click(object sender, EventArgs e)
42 | {
43 | Image img = Image.FromFile(ImagePath);
44 | Bitmap bitmap = new Bitmap(img);
45 | after_pic.Image = ImageLibrary.Gray.GrayScale(bitmap, 2);
46 | }
47 |
48 | private void btn_ImageGray2_Click(object sender, EventArgs e)
49 | {
50 | Image img = Image.FromFile(ImagePath);
51 | Bitmap bitmap = new Bitmap(img);
52 | after_pic.Image = ImageLibrary.Gray.GrayScale(bitmap, 1);
53 | }
54 |
55 | private void btn_ImageGray3_Click(object sender, EventArgs e)
56 | {
57 | Image img = Image.FromFile(ImagePath);
58 | Bitmap bitmap = new Bitmap(img);
59 | after_pic.Image = ImageLibrary.Gray.GrayScale(bitmap, 3);
60 | }
61 |
62 | private void btn_binary_Click(object sender, EventArgs e)
63 | {
64 | Image img = Image.FromFile(ImagePath);
65 | Bitmap bitmap = new Bitmap(img);
66 | var image = ImageLibrary.Gray.GrayScale(bitmap, 2);
67 | after_pic.Image = ImageLibrary.Gray.BinaryZation(image, int.Parse(txtthreshold.Text));
68 | }
69 |
70 |
71 |
72 | private void btn_pixelImage_Click(object sender, EventArgs e)
73 | {
74 | Image img = Image.FromFile(ImagePath);
75 | Bitmap bitmap = new Bitmap(img);
76 | var image = ImageLibrary.Gray.GrayScale(bitmap, 2);
77 | var BinaryImage = ImageLibrary.Gray.BinaryZation(image, int.Parse(txtthreshold.Text));
78 | var resultArray = ImageLibrary.Gray.PixelImage(BinaryImage);
79 |
80 |
81 | richTextBox1.Text = ImageLibrary.Util.EachArrayToString(resultArray);
82 | }
83 |
84 |
85 | private void btn_cut_Click(object sender, EventArgs e)
86 | {
87 | Image img = Image.FromFile(ImagePath);
88 | Bitmap bitmap = new Bitmap(img);
89 | var image = ImageLibrary.Gray.GrayScale(bitmap, 2);
90 | var BinaryImage = ImageLibrary.Gray.BinaryZation(image, int.Parse(txtthreshold.Text));
91 | var resultArray = ImageLibrary.Gray.PixelImage(BinaryImage);
92 |
93 | richTextBox1.Text = ImageLibrary.Util.GetValidRegion(resultArray);
94 |
95 | }
96 |
97 | private void btn_histogram_Click(object sender, EventArgs e)
98 | {
99 | Image img = Image.FromFile(ImagePath);
100 | Bitmap bitmap = new Bitmap(img);
101 |
102 | var histogramArray = ImageLibrary.Gray.GrayScaleHistogram(ImageLibrary.Gray.GrayScale(bitmap, 2));
103 |
104 |
105 | Graphics g = pic_histogram.CreateGraphics();
106 |
107 | Color red = Color.FromArgb(0, 0, 0);
108 | Pen blackPen = new Pen(red, 1);
109 | for (int i = 0; i < histogramArray.Length; i++)
110 | {
111 | Point point1 = new Point(i, 0); //坐标(100,100)
112 | Point point2 = new Point(i, histogramArray[i] ); //坐标(500,100)
113 | g.DrawLine(blackPen, point1, point2); //两个坐标连成直线
114 | }
115 |
116 |
117 | }
118 |
119 | private void btn_denoise_Click(object sender, EventArgs e)
120 | {
121 |
122 | after_pic.Image = ImageLibrary.Gray.NoiseReduction((Bitmap)after_pic.Image);
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/graph_cs/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/graph_cs/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | using System.Windows.Forms;
5 |
6 | namespace graph_cs
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// 应用程序的主入口点。
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new Form1());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/graph_cs/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("graph_cs")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("graph_cs")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("09dc19cb-6b0a-4f0a-b290-dec9c6d08ec0")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/graph_cs/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.18408
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace graph_cs.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("graph_cs.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/graph_cs/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/graph_cs/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.18408
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace graph_cs.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/graph_cs/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/graph_cs/graph_cs.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {79FE52C8-8885-4177-9BE6-4E8726E9EFAC}
8 | WinExe
9 | Properties
10 | graph_cs
11 | graph_cs
12 | v2.0
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | False
48 | C:\Users\Administrator\Desktop\tessnet2_32.dll
49 |
50 |
51 |
52 |
53 | Form
54 |
55 |
56 | Form1.cs
57 |
58 |
59 |
60 |
61 | Form1.cs
62 |
63 |
64 | ResXFileCodeGenerator
65 | Resources.Designer.cs
66 | Designer
67 |
68 |
69 | True
70 | Resources.resx
71 | True
72 |
73 |
74 | SettingsSingleFileGenerator
75 | Settings.Designer.cs
76 |
77 |
78 | True
79 | Settings.settings
80 | True
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | {86926ec7-c866-4e4e-a43e-a9e70fa2dd18}
89 | ImageLibrary
90 |
91 |
92 |
93 |
100 |
--------------------------------------------------------------------------------
/libtesseract302.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/libtesseract302.dll
--------------------------------------------------------------------------------
/pic/2013101809463539011.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/2013101809463539011.jpg
--------------------------------------------------------------------------------
/pic/plugin (1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (1).jpg
--------------------------------------------------------------------------------
/pic/plugin (2).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (2).jpg
--------------------------------------------------------------------------------
/pic/plugin (3).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (3).jpg
--------------------------------------------------------------------------------
/pic/plugin (4).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (4).jpg
--------------------------------------------------------------------------------
/pic/plugin (5).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (5).jpg
--------------------------------------------------------------------------------
/pic/plugin (6).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (6).jpg
--------------------------------------------------------------------------------
/pic/plugin (7).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin (7).jpg
--------------------------------------------------------------------------------
/pic/plugin.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/pic/plugin.jpg
--------------------------------------------------------------------------------
/tesseract-ocr-3.02.chi_sim.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/tesseract-ocr-3.02.chi_sim.tar.gz
--------------------------------------------------------------------------------
/tesseract-ocr-3.02.eng.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mz121star/CSharpImageLibrary/689ade1b63f7e99a97a2c5258bbb3c67cfc4c9d4/tesseract-ocr-3.02.eng.tar.gz
--------------------------------------------------------------------------------