圖形圖像處理(源代碼)_第1頁(yè)
圖形圖像處理(源代碼)_第2頁(yè)
圖形圖像處理(源代碼)_第3頁(yè)
圖形圖像處理(源代碼)_第4頁(yè)
圖形圖像處理(源代碼)_第5頁(yè)
已閱讀5頁(yè),還剩12頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、圖形圖像處理源代碼團(tuán)隊(duì)名稱:設(shè)計(jì)題目:院 組 員:指導(dǎo)教師:0private void timer1_Tick(object sender, EventArgs e)int x = label1.Left;int y = label1.Top;int w = label1.Width;int z = label1.Height;/x -= 4;x -= 25;/y += 3;if (x label1.Height)x = label1.Width;label1.SetBounds(x, y, w, z);private void WelcomeForm_Load(object sender,

2、EventArgs e)timer1.Enabled = true;timer2.Enabled = true;timer2.Interval = 2000;private void timer2_Tick(object sender, EventArgs e)MainForm mf = new MainForm();mf.Show();this.Hide();timer1.Enabled = false;timer2.Enabled = false;/主界面namespace GraphAndImagepublic partial class MainForm : Form1int i;in

3、t linewidth = 4;Graphics g;Color color=Color.Blue;ShowGraphForm sg = new ShowGraphForm();ShowImageForm si = new ShowImageForm();LineMadeForm lm = new LineMadeForm();public Bitmap SorceBitmap;public Bitmap MyBitmap;public MainForm()InitializeComponent();private void timer1_Tick(object sender, EventAr

4、gs e)/SystemTime.Text = DateTime.Now.ToString();private void MainForm_Load(object sender, EventArgs e)timer1.Start();LoginTime.Text = DateTime.Now.ToShortTimeString();private void AddImage_Click(object sender, EventArgs e)OpenFileDialog of = new OpenFileDialog();of.InitialDirectory = c:;of.Filter =

5、;of.RestoreDirectory = true;of.FilterIndex = 1;String fName;if (of.ShowDialog() = DialogResult.OK)fName = of.FileName;Image myImage = Image.FromFile(fName, true);pictureBox1.Image = myImage;imageList1.Images.Add(myImage);2private void SaveFile_Click(object sender, EventArgs e)SaveFileDialog sf = new

6、 SaveFileDialog();sf.InitialDirectory = c:;sf.Filter = ;sf.Title = 保存文件;sf.RestoreDirectory = true;sf.OverwritePrompt = true;sf.ShowDialog();private void OpenFile_Click(object sender, EventArgs e)OpenFileDialog of = new OpenFileDialog();of.InitialDirectory = c:;of.Filter = ;of.RestoreDirectory = tru

7、e;of.FilterIndex = 1;String fName;if (of.ShowDialog() = DialogResult.OK)fName = of.FileName;Image myImage = Image.FromFile(fName, true);imageList1.Images.Add(myImage);private void 直線 ToolStripMenuItem_Click(object sender, EventArgs e)sg = new ShowGraphForm();sg.Show();Graphics g = sg.CreateGraphics(

8、);Pen p = new Pen(color, linewidth);g.DrawLine(p, 50, 150, 300, 300);private void 多邊形 ToolStripMenuItem_Click(object sender, EventArgs e)sg = new ShowGraphForm();sg.Show();Graphics g = sg.CreateGraphics();Pen p = new Pen(color, linewidth);Point p1 = new Point(100, 20);3Point p2 = new Point(20, 120);

9、Point p3 = new Point(100, 100);Point p4 = new Point(260, 100);Point p5 = new Point(320, 120);Point p6 = new Point(260, 20);Point p0 =p1,p2,p3,p4,p5,p6;g.DrawPolygon(p,p0);private void 工具欄顯示 ToolStripMenuItem_Click(object sender, EventArgs e)if (工具欄顯示 ToolStripMenuItem.Checked = true &toolStrip1.Visi

10、ble = true)this.TopMost = false;this.工具欄顯示 ToolStripMenuItem.Checked = false;toolStrip1.Visible = false;elsethis.TopMost = true;this.工具欄顯示 ToolStripMenuItem.Checked = true;toolStrip1.Visible = true;private void 文字編輯 ToolStripMenuItem_Click(object sender, EventArgs e)richTextBox1.Visible = true;priva

11、te void 顏色設(shè)置 ToolStripMenuItem_Click(object sender, EventArgs e)ColorDialog fd = new ColorDialog();fd.AllowFullOpen = true;fd.FullOpen = true;fd.ShowHelp = true;fd.Color = Color.Blue;fd.ShowDialog();if (fd.ShowDialog() != DialogResult.Cancel)richTextBox1.SelectionColor = fd.Color;private void 字體設(shè)置 T

12、oolStripMenuItem_Click(object sender, EventArgs e)4FontDialog fd = new FontDialog();fd.Color = richTextBox1.ForeColor;fd.AllowScriptChange = true;fd.ShowColor = true;if (fd.ShowDialog() != DialogResult.Cancel)richTextBox1.SelectionFont = fd.Font;private void 貝塞爾樣條 2toolStripMenuItem2_Click(object se

13、nder, EventArgs e)sg = new ShowGraphForm();sg.Show();Graphics g = sg.CreateGraphics();Pen p = new Pen(color, linewidth);float sX = 50.0F;float sY = 80.0F;float cX1 = 150.0F;float cY1 = 20.0F;float cX2 = 230.0F;float cY2 = 50.0F;float eX = 190.0F;float eY = 80.0F;g.DrawBezier(p, sX, cX1, cY1, cX2, cY

14、2, eX, eY);private void 圖像分塊 2toolStripMenuItem4_Click(object sender, EventArgs e)si = new ShowImageForm();si.Show();MyBitmap = (Bitmap)this.imageList1.Imagesi;Graphics g = si.CreateGraphics();g.Clear(Color.White);int width = this.MyBitmap.Width;int height = this.MyBitmap.Height;RectangleF block =ne

15、w RectangleF(0, 0,width/3,height/3),new RectangleF(width/3,0,width/3,height/3),new RectangleF(2*width/3,0,width/3,height/3),5new RectangleF(2*width/3,height/3,width/3,height/3),new RectangleF(width/3,height/3,width/3,height/3),new RectangleF(0,height/3,width/3,height/3),new RectangleF(0,2*height/3,w

16、idth/3,height/3),new RectangleF(width/3,2*height/3,width/3,height/3),new RectangleF(2*width/3,2*height/3,width/3,height/3);Bitmap MyBitmapBlock =MyBitmap.Clone(block0,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block1,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block2

17、,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block3,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block4,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block5,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block6,System.Drawing.Imaging.PixelFor

18、mat.DontCare),MyBitmap.Clone(block7,System.Drawing.Imaging.PixelFormat.DontCare),MyBitmap.Clone(block8,System.Drawing.Imaging.PixelFormat.DontCare);g.DrawImage(MyBitmapBlock0, 255, 150);System.Threading.Thread.Sleep(1000);g.DrawImage(MyBitmapBlock1, 255 + width / 3, 150);System.Threading.Thread.Slee

19、p(1000);g.DrawImage(MyBitmapBlock2, 255 + 2 * width / 3, 150);System.Threading.Thread.Sleep(1000);g.DrawImage(MyBitmapBlock3, 255 + 2 * width / 3, 150 +height / 3);System.Threading.Thread.Sleep(1000);g.DrawImage(MyBitmapBlock4, 255 + width / 3, 150 + height /3);System.Threading.Thread.Sleep(1000);g.

20、DrawImage(MyBitmapBlock5, 255, 150 + height / 3);6System.Threading.Thread.Sleep(1000);g.DrawImage(MyBitmapBlock6, 255, 150 + 2 * height / 3);System.Threading.Thread.Sleep(1000);g.DrawImage(MyBitmapBlock7, 255 + width / 3, 150 + 2 *height / 3);height / 3);System.Threading.Thread.Sleep(1000);g.DrawIma

21、ge(MyBitmapBlock8, 255 + 2 * width / 3, 150 + 2 */特殊圖形namespace GraphAndImagepublic partial class TeShuGraphForm : Formint te = 0;public TeShuGraphForm()InitializeComponent();private void 三次貝濟(jì)埃曲線 toolStripMenuItem1_Click(objectsender, EventArgs e)huizhiquxian.Visible = false;huizhibeiziquxian.Visibl

22、e = false;this.Refresh();Graphics g = this.CreateGraphics();Pen pen1 = new Pen(Color.Black);g.Clear(this.BackColor);int cx, cy, i, n, xa, ya;int x = new int4 30, 100, 180, 280 ;int y = new int4 30, 110, 180, 30 ;n = 9;double t, t2, t3, a0, a1, a2, a3, b0, b1, b2, b3, dt;Point p1 = new Point();Point

23、p2 = new Point();cx = 10;cy = 160;a0 = x0; a1 = -3 * (x0 - x1);a2 = 3 * x0 - 6 * x1 + 3 * x2;7a3 = -x0 + 3 * x1 - 3 * x2 + x3;b0 = y0; b1 = -3 * (y0 - y1);b2 = 3 * y0 - 6 * y1 + 3 * y2;b3 = -y0 + 3 * y1 - 3 * y2 + y3;dt = 1.0 / n;for (i = 0; i = n; i+)t = i * dt;t2 = t * t;t3 = t2 * t;xa = (int)(a0

24、+ a1 * t + a2 * t2 + a3 * t3 + cx);ya = (int)(cy - (b0 + b1 * t + b2 * t2 + b3 * t3);if (i = 0)p1.X = xa; p1.Y = ya;elsep2.X = xa; p2.Y = ya;g.DrawLine(pen1, p1, p2);p1 = p2;private void button2_Click(object sender, EventArgs e)Color myBColor = this.BackColor;int intPt1 = int.Parse(textBox2.Text);in

25、t intPt1e = int.Parse(textBox3.Text);int intPt2 = int.Parse(textBox4.Text);int intPt2e = int.Parse(textBox5.Text);int intPt3 = int.Parse(textBox6.Text);int intPt3e = int.Parse(textBox7.Text);int intPt4 = int.Parse(textBox8.Text);int intPt4e = int.Parse(textBox9.Text);Point pt1 = new Point(intPt1, in

26、tPt1e);Point pt2 = new Point(intPt2, intPt2e);Point pt3 = new Point(intPt3, intPt3e);Point pt4 = new Point(intPt4, intPt4e);Pen myPen = new Pen(Color.Red);8Graphics myGraphic = this.CreateGraphics();myGraphic.Clear(myBColor);myGraphic.DrawBezier(myPen, pt1, pt2, pt3, pt4);private void button1_Click(

27、object sender, EventArgs e)Color myColor = this.BackColor;Point pt = new Point6;pt0 = new Point(50, 30);pt1 = new Point(100, 100);pt2 = new Point(150, 30);pt3 = new Point(200, 100);pt4 = new Point(250, 30);pt5 = new Point(300, 100);Pen myPenr = new Pen(Color.Red);Pen myPenb = new Pen(Color.Yellow, 5

28、);Pen myPend = new Pen(Color.Black, 5);Graphics myGraphic = this.CreateGraphics();myGraphic.Clear(myColor);float f = float.Parse(textBox1.Text);myGraphic.DrawCurve(myPenb, pt, f);for (float i = -1 * f; i 0)double k1 = y1 / x1;/第 1 段鈄率 k1/按第 1 段鈄率 k1 線性變換for (int i = 0; i = x1; i+)pMapi = (int)(k1 *

29、i);double k2 = (y2 - y1) / (x2 - x1);/第 2 段鈄率 k2/按第 2 段鈄率 k2 線性變換for (int i = x1 + 1; i = x2; i+)if (x2 != x1)pMapi = y1 + (int)(k2 * (i - x1);elsepMapi = y1;if (x2 255)double k3 = (255 - y2) / (255 - x2);/第 2 段鈄率 k2/按第 3 段鈄率 k3 線性變換for (int i = x2 + 1; i 256; i+)pMapi = y2 + (int)(k3 * (i - x2);ret

30、urn pMap;/對(duì)比度擴(kuò)展public Bitmap stretch(Bitmap bm, int map, int iw, int ih)Color c = new Color();int r, g, b;for (int j = 0; j ih; j+)for (int i = 0; i = 255) r = 255;if (r = 255) g = 255;if (g = 255) b = 255;if (b 0) b = 0;bm.SetPixel(i, j, Color.FromArgb(r, g, b);return bm;private void 直方圖變換增強(qiáng)_Click(

31、object sender, EventArgs e)if (curBitmap != null)Bitmap bm = new Bitmap(yutu.Image);/獲取直方圖int hist = gethist(bm, iw, ih);/直方圖均勻化bm = histequal(bm, hist, iw, ih);duibitu.Refresh();duibitu.Image = bm;label2.Text = 直方圖均衡化結(jié)果;flag = true;/獲取直方圖public int gethist(Bitmap bm, int iw, int ih)int h = new int2

32、56;for (int j = 0; j ih; j+)12for (int i = 0; i iw; i+)int grey = (bm.GetPixel(i, j).R;hgrey+;return h;/直方圖均衡化public Bitmap histequal(Bitmap bm, int hist, int iw, int ih)Color c = new Color();double p = (double)255 / (iw * ih);double sum = new double256;int outg = new int256;int g;sum0 = hist0;for (

33、int i = 1; i outgifor (int i = 0; i 256; i+)outgi = (int)(p * sumi);for (int j = 0; j ih; j+)for (int i = 0; i iw; i+)g = (bm.GetPixel(i, j).R;c = Color.FromArgb(outgg, outgg, outgg);bm.SetPixel(i, j, c);return bm;private void 嵌入 1_Click(object sender, EventArgs e)if (curBitmap != null)13keyDialog dialog = new ke

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論