圖形圖像處理課程設(shè)計報告_第1頁
已閱讀1頁,還剩8頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、<p><b>  Abstract </b></p><p>  Sketch picture processing has a very close contact with modernization life , so as the technology and research . As the sketch picture processing technique’s

2、fast development , people’s life are subjected to very big of influence.</p><p>  In the course design ,I have mainly practiced the basic operation sketch picture processing , which contains ash degree squar

3、e diagram ,the Rui turn of pictures and smooth etc.. According to these principle of the picture processing , including the ash degree of picture , and the picture strengthen filter etc.., I use the C# language realized

4、 the picture processing operation.</p><p>  Key Word: Sketch picture processing,ash degree square diagram,Rui turn,smooth</p><p><b>  摘 要</b></p><p>  圖形圖像處理是和現(xiàn)代化生活緊

5、密聯(lián)系不可分的,還有對科研方面等都有很大的貢獻(xiàn)。今年來隨著圖形圖像處理技術(shù)的快速發(fā)展,人們的生活都受到了很大的影響。</p><p>  在這次課程設(shè)計中,我主要練習(xí)了圖像處理基本的操作,包括圖像的灰度直方圖,圖像的銳化以及平滑等等。根據(jù)這些圖像處理的原理,包括圖像的灰度,圖像增強(qiáng)濾波器等等,用C#語言實現(xiàn)了上述的圖像處理操作。</p><p>  關(guān)鍵詞:圖形圖像處理,直方圖,銳化,平滑

6、</p><p>  圖形圖像處理課程設(shè)計報告</p><p><b>  一. 實驗要求</b></p><p>  (1). 讀入一幅圖像,要求統(tǒng)計各像素點灰度值并顯示該圖的灰度直方圖</p><p>  (2). 讀入一幅圖像,要求輸出該圖銳化后的圖像</p><p>  (3). 讀入一幅

7、圖像,要求顯示該圖平滑后的圖像</p><p><b>  二. 實驗設(shè)計</b></p><p>  1.實驗中的程序界面如下</p><p><b>  Form1</b></p><p><b>  Form2</b></p><p><b&

8、gt;  2.圖像處理設(shè)計</b></p><p>  (1). 灰度直方圖對一幅圖所有像素點具有的不同灰度值進(jìn)行統(tǒng)計并顯示出來,給出了一股圖的所有灰度值的整體描述。實驗中,若以i表示某個灰度值,則有0<=i<=256,以pix[i]表示灰度為i的像素點的個數(shù),當(dāng)畫直方圖的命令由form1傳遞到form2時,即采用GDI+畫出該直方圖</p><p>  (2).

9、銳化濾波器是圖像增強(qiáng)濾波器中的一種,它能減弱或消除傅里葉空間的低頻分量,但不影響高頻分量(從視覺效果上來看,就是突出有關(guān)形體的邊緣)。實驗中采用線性銳化濾波器,系數(shù)模板取拉普拉斯算子:</p><p>  (3). 平滑濾波器是圖像增強(qiáng)濾波器中的另一種,它能減弱或消除傅里葉空間中的高頻分量,但不影響高頻分量(從視覺效果上來看,就是把圖像給柔化了)。實驗中采用線性的平滑濾波器,系數(shù)模板取高斯算子:</p>

10、;<p><b>  三. 具體實現(xiàn)</b></p><p>  1. 程序中定義的全局參數(shù)有:</p><p>  From1: public int height, width; public int[] pix = new int[256];</p><p>  Form2 : public int hei, wi

11、d; public int[] pie</p><p><b>  2.傳參:</b></p><p>  既然涉及到兩個窗體,就必然要在兩個窗體之間傳遞參數(shù),當(dāng)某副圖片的像素與灰度信息已經(jīng)采集好時,就將灰度值數(shù)組傳遞到Form2中,接著用圖形設(shè)備接口函數(shù)畫出灰度直方圖</p><p>  /////Form1中的代碼</p>

12、<p>  private void button1_Click(object sender, EventArgs e)  </p><p><b>  {</b></p><p>  Form2 fm = new Form2(this);</p><p>  fm.Show();</p><p>&l

13、t;b>  }</b></p><p>  /////Form2中的代碼</p><p>  public Form2(Form1 fm)  </p><p><b>  {</b></p><p>  InitializeComponent();</p><p>  hei =

14、 fm.height;</p><p>  wid = fm.width;</p><p>  pie = fm.pix;</p><p><b>  }</b></p><p>  3.圖像灰度直方圖顯示</p><p>  先在Form1中定義函數(shù)統(tǒng)計讀入的圖像的像素點灰度信息,然后調(diào)用For

15、m2窗體進(jìn)行繪圖,代碼如下:</p><p>  /////Form1中的代碼</p><p>  height = this.pictureBox1.Image.Height;</p><p>  width = this.pictureBox1.Image.Width;</p><p>  Bitmap bitmap = (Bitmap)

16、this.pictureBox1.Image;</p><p>  Color pixel;</p><p>  int r = 0, b = 0, g = 0;</p><p>  for (int i = 0; i < 256; i++) pix[i] = 0;</p><p>  for (int i = 1; i < wi

17、dth; i++)</p><p>  for (int j = 1; j < height; j++)</p><p><b>  {</b></p><p>  pixel = bitmap.GetPixel(i, j);</p><p>  r = pixel.R;</p><p> 

18、 g = pixel.G;</p><p>  b = pixel.B;</p><p>  int a = (int)(r + b + g) / 3;</p><p>  pix[a]++; ////統(tǒng)計灰度值為a的像素點數(shù)目</p><p><b>  }</b></p><p>

19、;  /////Form2中的代碼</p><p>  Bitmap image = new Bitmap(300, 300);</p><p>  Graphics g = Graphics.FromImage(image);</p><p>  g.Clear(Color.White);</p><p>  Font font = new

20、 Font("宋體", 10, FontStyle.Bold);</p><p>  Brush brush = Brushes.Blue;</p><p>  g.DrawString("灰度直方圖", font, brush, new Point(15, 10));</p><p>  Pen mypen = new Pe

21、n(brush, 1);</p><p><b>  //繪制X軸;</b></p><p>  g.DrawLine(mypen, 10, 260, 280, 260);</p><p>  g.DrawLine(mypen, 276, 258, 280, 260);</p><p>  g.DrawLine(mype

22、n, 276, 262, 280, 260);</p><p><b>  //繪制Y軸;</b></p><p>  g.DrawLine(mypen, 10, 10, 10, 260);</p><p>  g.DrawLine(mypen, 8, 16, 10, 10);</p><p>  g.DrawLine(

23、mypen, 12, 16, 10, 10);</p><p>  for (int i = 0; i < 256; i++)</p><p><b>  {</b></p><p>  g.DrawLine(mypen, 10 + i, 260, 10 + i, 260 - (int)(7000 * pie[i] / (hei * wi

24、d)));</p><p>  if (i % 50 == 0)</p><p>  g.DrawString(i.ToString(), new Font("正楷", 8, FontStyle.Regular), brush, new Point(10 + i, 262));</p><p><b>  }</b><

25、/p><p>  this.pictureBox1.Image = image;</p><p><b>  4.圖像銳化處理</b></p><p>  如實驗設(shè)計所描述的,采用拉普拉斯算子對原圖像進(jìn)行銳化,程序如下:</p><p>  int height = this.pictureBox1.Image.Height

26、;</p><p>  int width = this.pictureBox1.Image.Width;</p><p>  Bitmap newBitmap = new Bitmap(width, height);</p><p>  Bitmap oldBitmap = (Bitmap)this.pictureBox1.Image;</p>&l

27、t;p>  Color pixel;</p><p>  int[] Laplacian ={ -1, -1, -1, -1, 9, -1, -1, -1, -1 }; ////拉普拉斯算子</p><p>  for (int x = 1; x < width - 1; x++)</p><p>  for (int y = 1; y < hei

28、ght - 1; y++)</p><p><b>  {</b></p><p>  int r = 0, g = 0, b = 0;</p><p>  int index = 0;</p><p>  for (int col = -1; col <= 1; col++)</p><p&g

29、t;  for (int row = -1; row <= 1; row++)</p><p><b>  {</b></p><p>  pixel = oldBitmap.GetPixel(x + row, y + col);</p><p>  r += pixel.R * Laplacian[index];</p>

30、<p>  g += pixel.G * Laplacian[index];</p><p>  b += pixel.B * Laplacian[index]; ////計算變換后的像素點的像素值</p><p><b>  index++;</b></p><p><b>  }</b></p>

31、;<p>  r = r > 255 ? 255 : r; ////判斷是否溢出</p><p>  r = r < 0 ? 0 : r;</p><p>  g = g > 255 ? 255 : g;</p><p>  g = g < 0 ? 0 : g;</p><p>  b = b &

32、gt; 255 ? 255 : b;</p><p>  b = b < 0 ? 0 : b;</p><p>  newBitmap.SetPixel(x - 1, y - 1, Color.FromArgb(r, b, g));</p><p><b>  }</b></p><p>  this.pictur

33、eBox2.Image = newBitmap;</p><p><b>  5.圖像平滑處理</b></p><p>  如實驗設(shè)計所描述的,采用高斯算子對原圖像進(jìn)行銳化,程序如下:</p><p>  int height = this.pictureBox1.Image.Height;</p><p>  int

34、width = this.pictureBox1.Image.Width;</p><p>  Bitmap newBitmap = new Bitmap(width, height);</p><p>  Bitmap oldBitmap = (Bitmap)this.pictureBox1.Image;</p><p>  Color pixel;</p&

35、gt;<p>  int[] Gauss ={ 1, 2, 1, 2, 4, 2, 1, 2, 1 }; ////高斯算子</p><p>  for (int x = 1; x < width - 1; x++)</p><p>  for (int y = 1; y < height - 1; y++)</p><p><

36、b>  {</b></p><p>  int r = 0, g = 0, b = 0;</p><p>  int index = 0;</p><p>  for (int col = -1; col <= 1; col++)</p><p>  for (int row = -1; row <= 1; ro

37、w++)</p><p><b>  {</b></p><p>  pixel = oldBitmap.GetPixel(x + row, y + col);</p><p>  r += pixel.R * Gauss[index];</p><p>  g += pixel.G * Gauss[index];<

38、;/p><p>  b += pixel.B * Gauss[index];</p><p><b>  index++;</b></p><p><b>  }</b></p><p>  r /= 16; g /= 16; b /= 16; ////得到變換后的像素點像素值&

39、lt;/p><p>  r = r > 255 ? 255 : r;</p><p>  r = r < 0 ? 0 : r;</p><p>  g = g > 255 ? 255 : g;</p><p>  g = g < 0 ? 0 : g;</p><p>  b = b > 255

40、 ? 255 : b;</p><p>  b = b < 0 ? 0 : b; /////判斷是否溢出</p><p>  newBitmap.SetPixel(x - 1, y - 1, Color.FromArgb(r, b, g));</p><p><b>  }</b></p>&l

41、t;p>  this.pictureBox2.Image = newBitmap;</p><p>  6.變換后圖像灰度直方圖顯示</p><p>  這個模塊同第三個模塊差不多,只是讀取圖像的對象不同:</p><p>  height = this.pictureBox2.Image.Height;</p><p>  width

42、 = this.pictureBox2.Image.Width;</p><p>  Bitmap bitmap = (Bitmap)this.pictureBox2.Image;</p><p><b>  四. 實驗結(jié)果</b></p><p>  1.實驗中采用的圖像如下所示:</p><p><b> 

43、 2.原圖直方圖顯示</b></p><p>  3.銳化后的圖像顯示</p><p>  4.銳化后的圖像灰度直方圖顯示:</p><p>  5.平滑后的圖像顯示:</p><p>  6.平滑后圖像灰度直方圖顯示:</p><p><b>  五. 實驗總結(jié)</b></p&

44、gt;<p>  因為對C++語言的不熟悉,這次實驗我是基于C#語言完成的,所以從效果上來說比不上用C++與語言做出的圖像效果 。</p><p>  在圖形圖像處理課程設(shè)計中,我學(xué)到了不少的東西,并且做出這些之后感覺很興奮,比較有趣味性,突然發(fā)現(xiàn)對這方面比較感興趣了。不過鑒于自己對于圖像處理方面了解的知識還很少,以后會慢慢加強(qiáng)學(xué)習(xí)的。</p><p>  謝謝xx老師在這次

溫馨提示

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

評論

0/150

提交評論