資源簡介
C#圖像的加噪去噪 ,用于課程實驗 完整的源代碼

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?圖像平滑和去噪
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?string?curfilename;
????????private?System.Drawing.Bitmap?curbitmap;
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?ofd?=?new?OpenFileDialog();
????????????ofd.Filter?=?“所有圖像文件?|?*.bmp;?*.pcx;?*.png;?*.jpg;?*.gif;“?+
????????????????“*.tif;?*.ico;?*.dxf;?*.cgm;?*.cdr;?*.wmf;?*.eps;?*.emf|“?+
????????????????“位圖(?*.bmp;?*.jpg;?*.png;...)?|?*.bmp;?*.pcx;?*.png;?*.jpg;?*.gif;?*.tif;?*.ico|“?+
????????????????“矢量圖(?*.wmf;?*.eps;?*.emf;...)?|?*.dxf;?*.cgm;?*.cdr;?*.wmf;?*.eps;?*.emf“;
????????????ofd.title?=?“?打開圖像文件“;
????????????ofd.ShowHelp?=?true;
????????????if?(ofd.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????curfilename?=?ofd.FileName;
????????????????try
????????????????{
????????????????????curbitmap?=?(Bitmap)Image.FromFile(curfilename);
????????????????}
????????????????catch?(Exception?exp)
????????????????{
????????????????????MessageBox.Show(exp.Message);
????????????????}
????????????}
????????????Invalidate();
????????}
????????private?void?Form1_Paint_1(object?sender?PaintEventArgs?e)
????????{
????????????Graphics?g?=?e.Graphics;
????????????if?(curbitmap?!=?null)
????????????{
????????????????g.DrawImage(curbitmap?0?0?curbitmap.Width?curbitmap.Height);
????????????}
????????}
????????//疊加噪聲
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????if?(curbitmap?!=?null)
????????????{
????????????????noiseForm?noise?=?new?noiseForm();
????????????????if?(noise.ShowDialog()?==?DialogResult.OK)
????????????????{
????????????????????Rectangle?rect?=?new?Rectangle(0?0?curbitmap.Width?curbitmap.Height);
????????????????????System.Drawing.Imaging.BitmapData?bmpdata?=?curbitmap.LockBits(rect?System.Drawing.Imaging.ImageLockMode.ReadWrite?curbitmap.PixelFormat);
????????????????????IntPtr?ptr?=?bmpdata.Scan0;
????????????????????int?bytes?=?curbitmap.Width*curbitmap.Height*3;
????????????????????byte[]?grayvalues?=?new?byte[bytes];
????????????????????System.Runtime.InteropServices.Marshal.Copy(ptr?grayvalues?0?bytes);
????????????????????double?temp?=?0;
????????????????????double[]?paranoise?=?new?double[2];
????????????????????paranoise?=?noise.Getparan;
????????????????????Random?r1r2;
????????????????????r1?=?new?Random(unchecked((int)DateTime.Now.Ticks));
????????????????????r2?=?new?Random(~unchecked((int)DateTime.Now.Ticks));
????????????????????double?v1?v2;
????????????????????for?(int?i?=?0;?i?????????????????????{
????????????????????????do
????????????????????????{
???????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????953??2010-11-17?13:33??圖像平滑和去噪\image?smoothing.sln
????..A..H.?????15872??2012-06-28?20:13??圖像平滑和去噪\image?smoothing.suo
?????文件??????15360??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\bin\Debug\圖像平滑和去噪.exe
?????文件??????46592??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\bin\Debug\圖像平滑和去噪.pdb
?????文件??????14328??2012-06-28?20:13??圖像平滑和去噪\圖像平滑和去噪\bin\Debug\圖像平滑和去噪.vshost.exe
?????文件????????490??2009-06-11?05:14??圖像平滑和去噪\圖像平滑和去噪\bin\Debug\圖像平滑和去噪.vshost.exe.manifest
?????文件??????12119??2011-06-22?15:40??圖像平滑和去噪\圖像平滑和去噪\Form1.cs
?????文件???????4651??2010-11-18?18:36??圖像平滑和去噪\圖像平滑和去噪\Form1.Designer.cs
?????文件???????5814??2010-11-18?18:36??圖像平滑和去噪\圖像平滑和去噪\Form1.resx
?????文件???????1088??2010-11-17?14:10??圖像平滑和去噪\圖像平滑和去噪\noiseForm.cs
?????文件???????5479??2010-11-17?14:08??圖像平滑和去噪\圖像平滑和去噪\noiseForm.Designer.cs
?????文件???????5814??2010-11-17?14:08??圖像平滑和去噪\圖像平滑和去噪\noiseForm.resx
?????文件???????2062??2012-06-28?20:13??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.csproj.FileListAbsolute.txt
?????文件????????909??2011-06-22?15:40??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.csproj.GenerateResource.Cache
?????文件??????15360??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.exe
?????文件????????180??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.Form1.resources
?????文件????????180??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.noiseForm.resources
?????文件??????46592??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.pdb
?????文件????????180??2012-06-28?20:12??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\圖像平滑和去噪.Properties.Resources.resources
?????文件????????502??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Program.cs
?????文件???????1386??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Properties\AssemblyInfo.cs
?????文件???????2892??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Properties\Resources.Designer.cs
?????文件???????5612??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Properties\Resources.resx
?????文件???????1106??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Properties\Settings.Designer.cs
?????文件????????249??2010-11-17?13:33??圖像平滑和去噪\圖像平滑和去噪\Properties\Settings.settings
?????文件???????4161??2010-11-17?16:18??圖像平滑和去噪\圖像平滑和去噪\圖像平滑和去噪.csproj
????..A..H.?????17408??2011-03-28?11:13??圖像平滑和去噪\圖像平滑和去噪.suo
?????目錄??????????0??2011-04-21?13:24??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\Refactor
?????目錄??????????0??2011-04-21?13:24??圖像平滑和去噪\圖像平滑和去噪\obj\Debug\TempPE
?????目錄??????????0??2012-07-13?11:47??圖像平滑和去噪\圖像平滑和去噪\bin\Debug
............此處省略9個文件信息
- 上一篇:C#會員積分管理系統
- 下一篇:c# DATAGRID使用方法
評論
共有 條評論