肺癌 - ucl.com.tw¹´國人十大死因... · 來源:衛生福利部 統計處 104年癌症(惡性腫瘤)死亡人數為46,829人,占所 有死亡人數的28.6%,死亡率每十萬人口199.6人,較
Digital Image Processing 數位影像處理
description
Transcript of Digital Image Processing 數位影像處理
![Page 1: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/1.jpg)
1
Digital Image Processing數位影像處理江政杰
![Page 2: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/2.jpg)
2
What’s An Image
數位影像
Unit: Pixel
![Page 3: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/3.jpg)
3
Image Type• Gray 灰階影像• Color 彩色影像
800x600=480000 pixels
每個 pixel 是由三個値組成 (R, G, B)
每個 pixel 是由一個値組成
![Page 4: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/4.jpg)
4
Gray Image
Image I 可以表示成}4800001|{ iII i
or}6001 ,8001|{ jiII ij
double *Image=NULL;
Image = (double *) malloc(width * height * sizeof(double));
// read a gray image filefor (i = 0 ; i < height ; i++ ) for (j = 0 ; j < width ; j++){ fscanf(fpin, "%c", &pixel); *(Image+i*width+j)=(double)pixel; //the pixel at (i, j) }
![Page 5: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/5.jpg)
5
Color Image
Image I 可以表示成}4800001| ))( ),( ),({( iBIGIRII iii
or
},8001 ,8001
| ))( ),( ),({(
ii
BIGIRII ijijij
double *Image=NULL;
Image = (double *) malloc(width * height * sizeof(double)*3);
// read a gray image filefor (i = 0 ; i < height ; i++ ) for (j = 0 ; j < width ; j++){ fscanf(fpin, "%c", &pixel); *(Image+i*width+j)=(double)pixel; //R at pixel (i, j) fscanf(fpin, "%c", &pixel); *(Image+i*width+j+1)=(double)pixel; //G at pixel (i, j) fscanf(fpin, "%c", &pixel); *(Image+i*width+j+2)=(double)pixel; //B at pixel (i, j) }
![Page 6: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/6.jpg)
6
Image Features• Feature: 特徵
影像的 pixel 一般都非常多 , 我們要在其中找到可以代表不同影像的特徵• 目前常見的影像特徵種類很多 , 可分成
– Color: 以顏色為主– Texture: 以材質為主– Shape: 以形狀為主– …
![Page 7: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/7.jpg)
7
Pixel Feature• 最簡單的特徵取法就是
把所有 pixel 排列出來這種方式只適合在小的影像 , 例如一個 icon 是 32x32=1024 pixels目前在 face detection 上很多就是用 pixel feature 直接表示影像特徵
}4800001|{ iII i
![Page 8: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/8.jpg)
8
Color Histogrampixel數量
亮度值0 255
histogram 是最常用也是最簡單的影像特徵表示法histogram 是一種統計的方式表示顏色變化與分佈狀況
在 color image, 可以針對 R, G, B 分別算 histogram
以上面的例子看 , color histogram 會轉換成 256 維度的向量
![Page 9: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/9.jpg)
9
Color Moments• 因為 color histogram 的維度一般都很高 , 所以用統計的計量再予以精簡
這 480000 個値可以計算其平均數與變異數 , 用這兩個統計量代表一張影像
• Color Image– R, G, B channels, 各有平均數與變異數– 共六個値代表 , 所以是 6 維的向量
}4800001|{ iII i
![Page 10: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/10.jpg)
10
OpenCV Setup in VC• Library: project->setting->link
– cv.lib cvaux.lib highgui.lib cxcore.lib• Directories
– Include• C:\PROGRAM FILES\OPENCV\CV\INCLUDE• C:\PROGRAM FILES\OPENCV\CVAUX\INCLUDE• C:\PROGRAM FILES\OPENCV\OTHERLIBS\HIGHGUI• C:\PROGRAM FILES\OPENCV\CXCORE\INCLUDE
– Library• C:\PROGRAM FILES\OPENCV\LIB
– FilePathName• C:\PROGRAM FILES\OPENCV\bin
• Include in programs– #include "cv.h“, "cvaux.h“, "highgui.h“, "cxcore.h"
![Page 11: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/11.jpg)
11
#include <stdio.h>#include <cxcore.h>#include <highgui.h>#include <math.h>
int main( int argc, char** argv ) { CvPoint center; double scale=-3;
IplImage* image = cvLoadImage("Beach 2.jpg"); if(!image) return -1;/* 這一段程式將每個 pixel 逐一調整成整張圖有漸層 center = cvPoint(image->width/2,image->height/2); for(int i=0;i<image->height;i++) for(int j=0;j<image->width;j++) { double dx=(double)(j-center.x)/center.x; double dy=(double)(i-center.y)/center.y; double weight=exp((dx*dx+dy*dy)*scale); uchar* ptr = &CV_IMAGE_ELEM(image,uchar,i,j*3); ptr[0] = cvRound(ptr[0]*weight); ptr[1] = cvRound(ptr[1]*weight); ptr[2] = cvRound(ptr[2]*weight); } cvSaveImage("copy.png", image );*/ cvNamedWindow("test", 1 ); cvShowImage("test", image ); cvWaitKey(); return 0; }
Including files
主程式開始OpenCV 內定的資料型態 可以直接用
讀取 jpeg 檔 , 內定函數 , 輸入參數是字串
產生一個新的視窗將影像顯示在視窗內等待按任一鍵
![Page 12: Digital Image Processing 數位影像處理](https://reader036.fdocuments.us/reader036/viewer/2022081505/56814d52550346895dba8a49/html5/thumbnails/12.jpg)
12
工 作1. 熟悉 Visual C++ (or VC .net)2. 將 OpenCV 安裝到可以執行3. 程式 : 輸入一張影像 , 然後秀出這張影像4. 研讀 face detection 與影片處理的相關資訊