Title: Digital Image Processing ??????
1Digital Image Processing??????
2Whats An Image
????
Unit Pixel
3Image Type
800x600480000 pixels
??pixel??????? (R, G, B)
??pixel???????
4Gray Image
Image I ?????
or
double ImageNULL Image (double )
malloc(width height sizeof(double)) // read
a gray image file for (i 0 i lt height i
) for (j 0 j lt width j)
fscanf(fpin, "c", pixel)
(Imageiwidthj)(double)pixel //the pixel
at (i, j)
5Color Image
Image I ?????
or
double ImageNULL Image (double )
malloc(width height sizeof(double)3) //
read a gray image file for (i 0 i lt height
i ) for (j 0 j lt width j)
fscanf(fpin, "c", pixel) (Imageiwidthj)(d
ouble)pixel //R at pixel (i, j)
fscanf(fpin, "c", pixel) (Imageiwidthj1)(
double)pixel //G at pixel (i, j)
fscanf(fpin, "c", pixel) (Imageiwidthj2)(
double)pixel //B at pixel (i, j)
6Image Features
- Feature ??
- ???pixel??????, ???????????????????
- ?????????????, ???
- Color ?????
- Texture ?????
- Shape ?????
7Pixel Feature
- ??????????
-
- ???pixel????
- ????????????, ????icon?32x321024 pixels???face
detection??????pixel feature????????
8Color Histogram
pixel??
0
255
???
histogram ?????????????????
histogram ???????????????????
???????, color histogram????256?????
?color image, ????R, G, B ???histogram
9Color Moments
- ??color histogram????????, ?????????????
-
- ?480000??????????????, ?????????????
- Color Image
- R, G, B channels, ?????????
- ??????, ???6????
10OpenCV Setup in VC
- Library project-gtsetting-gtlink
- 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"
11include ltstdio.hgt include ltcxcore.hgt include
lthighgui.hgt include ltmath.hgt 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-gtwidth/2,image-gtheight/2)
for(int i0iltimage-gtheighti) for(int
j0jltimage-gtwidthj) double
dx(double)(j-center.x)/center.x
double dy(double)(i-center.y)/center.y
double weightexp((dxdxdydy)scale)
uchar ptr CV_IMAGE_ELEM(image,uchar,i,j3)
ptr0 cvRound(ptr0weight)
ptr1 cvRound(ptr1weight)
ptr2 cvRound(ptr2weight)
cvSaveImage("copy.png", image ) /
cvNamedWindow("test", 1 ) cvShowImage("test",
image ) cvWaitKey() return 0
Including files
?????
OpenCV??????? ?????
??jpeg?, ????, ???????
????????
?????????
??????
12? ?
- ??Visual C (or VC .net)
- ?OpenCV???????
- ?? ??????, ????????
- ??face detection??????????