2010年3月7日 星期日

HW02: Image-Level Processing in OpenCV

1. Download HW02.cpp from webhd.mcu.edu.tw.
2. Excute and trace the program.
3. Study the codes.
4. Extend HW01.cpp to generate three videos. The first one is gray-level video. The second one is the black and white video. The third one is a video with edges only. Note that you need to use cvFlip() function to change the display of videos.



註解程式碼
5. Modify the vaue of the third parameter in
cvThreshold( gray, bw, 127, 255, CV_THRESH_BINARY );
such that your face becomes black.
6. Find the differences between
cvThreshold( gray, bw, 127, 255, CV_THRESH_BINARY );
從灰階轉換為黑白,127以及255為門檻值,如果要加深讓臉部變成黑色,就把門檻值調高
cvThreshold( pImg, pImg2, 127, 255, CV_THRESH_BINARY );
將彩色轉為黑白 有就是255,沒有就是0
7. How many colors in the pImg2 image?
2^3=8 因為R,G,B(0以及255兩種)
8. Use cvResize() function to extend HW02.cpp such that the displayed image is enlarged by a factor of 3.14.
要先在畫出一個視窗,des的視窗大小就是src視窗大小*3.14
使用Resize(src,des,CV_INTER_LINEAR)
將src的圖檔大小丟到des裡面,並且使用CV_INTER_LINEAR演算法



註解程式碼
9. (Optional) Study functions of cvDilate() and cvErode().
心得:

這次看的程式碼是做影像的處理,分別將彩色的照片轉換為灰階、黑白、以及繪出邊線,等方式,
老師在上課的時候會把使用的函式講清楚,所以可以在程式碼旁邊註解就好,今天學到的比較難
一點的是把視訊轉換為灰階那些處理,一開始就發現轉換出來畫面會變成顛倒的狀況,老師解釋是因為再做二維陣列處理的時候會將影像轉換,才會有這樣的狀況,所以只要再做一次cvFlip就可以解決了。另外再放大的時候,會出現警告訊息,是因為放大的倍率必須是整數(int)的形式才行。

沒有留言:

張貼留言