Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park.

Similar presentations


Presentation on theme: "Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park."— Presentation transcript:

1 Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park

2 중간고사 ! 10 월 15 일 월요일 오후 7 시 ~9 시 충무관 210 호 필기고사

3 Outline Review Topics for the term project

4 What you’ve learned so far: OpenCV Image Processing –Image filtering Brightness/Contrast Gamma Histogram Equalization Blur Filtering Unsharp Filter –Image Warping Scaling/Rotation/Shearing Translation Recovering Transformation Image Morphing

5 HelloCV #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("HelloCV"); cvShowImage("HelloCV", img); cvWaitKey(); cvDestroyWindow("HelloCV"); cvReleaseImage(&img); return 0; } IplImage cvLoadImage cvReleaseImage cvNamedWindow cvShowImage cvDestroyWindow cvWaitKey

6 Image structure IplImage (Image Processing Library) typedef struct _IplImage { int nSize; /* size of iplImage struct */ int ID; /* image header version */ int nChannels; int alphaChannel; int depth; /* pixel depth in bits */ char colorModel[4]; char channelSeq[4]; int dataOrder; int origin; int align; /* 4- or 8-byte align */ int width; int height; struct _IplROI *roi; /* pointer to ROI if any */ struct _IplImage *maskROI; /*pointer to mask ROI if any */ void *imageId; /* use of the application */ struct _IplTileInfo *tileInfo; /* contains information on tiling*/ int imageSize; /* useful size in bytes */ char *imageData; /* pointer to aligned image */ int widthStep; /* size of aligned line in bytes */ int BorderMode[4]; /* the top, bottom, left,and right border mode */ int BorderConst[4]; /* constants for the top, bottom,left, and right border */ char *imageDataOrigin; /* ptr to full, nonaligned image */ } IplImage;

7 Image I/O IplImage* cvLoadImage(image_path, colorness_flag); loads image from file, converts to color or grayscle, if need, and returns it (or returns NULL). image format is determined by the file contents. #define CV_LOAD_IMAGE_COLOR 1 #define CV_LOAD_IMAGE_GRAYSCALE 0 #define CV_LOAD_IMAGE_UNCHANGED -1  DEFAULT cvSaveImage(image_path, image); saves image to file, image format is determined from extension. cvReleaseImage(image_path, image); releases memory BMP, JPEG, PNG, TIFF, PPM/PGM formats are supported. IplImage* img = cvLoadImage(“picture.jpeg”,-1); if( img ) cvSaveImage( “picture.bmp”, img );

8 Windows cvNamedWindow(window_name, fixed_size_flag); creates window accessed by its name. Window handles repaint, resize events. Its position is remembered in registry: cvNamedWindow(“ViewA”); cvMoveWindow(“ViewA”,300,100); cvDestroyWindow(“ViewA”); … cvShowImage(window_name, image); copies the image to window buffer, then repaints it when necessary. {8u|16s|32s|32f}{C1|3|4} are supported. only the whole window contents can be modified. Dynamic updates of parts of the window are done using operations on images, drawing functions etc. cvDestroyWindow(window_name); deletes the window with the given name

9 User Input int cvWaitKey( int delay=0 ) waits for a pressed key. After waiting for the given delay, it proceeds. Zero delay means waiting forever until user input. –Delay in milliseconds.  Good for animating something Example) swapping between two images

10 Mouse Callback Two things you have to do: –Implementation Define what you are going to do when events happen –Setting (registration) Let the OpenCV know which one is the callback function void cvSetMouseCallback(window_name, yourFunction) void yourFunction (int event, int x, int y, int flags, void *param);

11 Draw Line void cvLine( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1); Draw Line from pt1 to pt2 with the given thickness CvPoint: a structure for storing 2D position –Use cvPoint(x,y) for a quick usage. struct CvPoint { int x; // x-coordinate int y; // y-coordinate } struct CvPoint { int x; // x-coordinate int y; // y-coordinate }

12 Draw Rectangle void cvRectangle( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1 ) void cvRectangle( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1 ) Draw a rectangle with two opposite corners pt1 and pt2 pt1 pt2 What happens if thickness is -1?

13 Draw Circle void cvCircle( IplImage, CvPoint center, int radius, CvScalar color, int thickness=1 ) void cvCircle( IplImage, CvPoint center, int radius, CvScalar color, int thickness=1 ) Draw a circle with given center and radius center radius

14 Image Processing image filtering: change range of image g(x) = h(f(x)) image warping: change domain of image g(x) = f(h(x)) h fg h f g Alexei Efros

15 Image Filtering 1 Brightness/contrast input output g = Af + B g = input color value f = output color value A = contrast value ( 초기값 = 1) B = brightness value ( 초기값 = 0)

16 Gamma Image Filtering 2

17 Histogram Equalization: Modify the image to have a well-distributed histogram Image Filtering 3

18 Histogram Equalization Procedure: For each color channel (R, G, B) –1. Compute the histogram –2. Compute the cumulative histogram –3. Set the maximum value as 255 –4. Using the cumulative histogram as a mapping function 255 192 128 64 0

19 Image Filtering 4: Cross-correlation filtering: or it can be written as: H is called the “filter,” “kernel,” or “mask.”

20 Image Filtering 4-1 Blur filter: 3x3 Mean kernel 1/9 0000000000 0000000000 00090 00 000 00 000 00 000 0 00 000 00 0000000000 00 0000000 0000000000 u01 v 0 1

21 Image Filtering 4-2 Blur filter: 3x3 Gaussian kernel 121 242 121 0000000000 0000000000 00090 00 000 00 000 00 000 0 00 000 00 0000000000 00 0000000 0000000000

22 Image Filtering 4-3 Median Filter: selecting the median intensity in the window. 0000000000 0000000000 00090 00 000 00 000 00 000 0 00 000 00 0000000000 00 0000000 0000000000 000 0 0 000 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 90 Median( 중간값 )

23 Image Filtering 5: Unsharp Masking = +  blurreddifferenceoriginal - = blurreddifference

24 Image Processing image filtering: change range of image g(x) = h(f(x)) image warping: change domain of image g(x) = f(h(x)) h fg h f g Alexei Efros

25 Image Warping Homogeneous coordinates –represent coordinates in 2 dimensions with a 3-vector ( 동차좌표 )

26 Basic 2D transformations as 3x3 matrices Translate Rotate Scale Image Warping

27 Affine transformations : –Combinations of … Linear transformations, and Translations –Properties of affine transformations: Origin does not necessarily map to origin Lines map to lines Ratios are preserved Parallel lines remain parallel Closed under composition Models change of basis ( 유사변환 ) Image Warping

28 Projective transformations : –Combinations of.. Affine transformations, and Projective warps –Properties of projective transformations: Origin does not necessarily map to origin Lines map to lines Ratios are not preserved Parallel lines do not necessarily remain parallel Closed under composition Models change of basis ( 사영변환 ) Image Warping

29 Matrix Composition p’ = T(t x,t y ) R(  ) S(s x,s y ) p Sequence of composition 1.First, Scaling 2.Next, Rotation 3.Finally, Translation Image Warping

30 Keyframe animation: Interpolation of state vector: 1-αα α Image Warping

31 Image Morphing: Cross-Dissolve Interpolate whole images: Image halfway = (1-t)*Image 1 + t*image 2 This is called cross-dissolve in film industry But what is the images are not aligned?

32 Image Morphing : cross-disolve2 Align first, then cross-dissolve –Alignment using global warp – picture still valid

33 General Image Morphing Procedure 1.Create an intermediate shape (by interpolation) 2.Warp both images towards it 3.Cross-dissolve the colors in the newly warped images


Download ppt "Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park."

Similar presentations


Ads by Google