Presentation is loading. Please wait.

Presentation is loading. Please wait.

MA/CS 3751 Fall 2002 Lecture 24. MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image.

Similar presentations


Presentation on theme: "MA/CS 3751 Fall 2002 Lecture 24. MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image."— Presentation transcript:

1 MA/CS 3751 Fall 2002 Lecture 24

2 MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image output: x and y Matlab functions

3 MA/CS 3753 ginput Cross hairs appear, then click to select point. Matlab functions

4 MA/CS 3754 interp2 ZI = INTERP2(X,Y,Z,XI,YI) interpolates to find ZI, the values of the underlying 2-D function Z at the points in matrices XI and YI. Matrices X and Y specify the points at which the data Z is given. Out of range values are returned as NaN. X, Y must be a regular grid of data (i.e. created with meshgrid)

5 MA/CS 3755 interp2 (interpolation of rectangular array data) Matlab functions

6 MA/CS 3756 griddata griddata does the same as interp2 however the input data can be given at arbitrarily spaced points. ZI = GRIDDATA(X,Y,Z,XI,YI) fits a surface of the form Z = F(X,Y) to the data in the (usually) nonuniformly-spaced vectors (X,Y,Z) GRIDDATA interpolates this surface at the points specified by (XI,YI) to produce ZI. The surface always goes through the data points. XI and YI are usually a uniform grid

7 MA/CS 3757 griddata Matlab functions

8 MA/CS 3758 Team Project Introduction –Each team is going to work on the same type of project. –All presentation rules for homework apply to the team project. –All coding must be done in Matlab

9 MA/CS 3759 General Project Topic Image tweening. i.e. given two or more images we are going to write routines that create intermediate images Morphing using non-linear maps Examples… More details:

10 MA/CS 37510 Part 1 Devise a one page team plan It should address what part each team member will work on

11 MA/CS 37511 Part 2 Load in two images using imread Crop the images to be the size of the smaller image. Display the images in the same window using subplot Let the “user” select a set of control point pairs [CXleft,CYleft] and [CXright,CYright]. i.e. a control point pair consists of one 2D point from each picture. Use ginput Plot a * at each point in the left picture and a + at each point in the right picture, using plot Board demo

12 MA/CS 37512 Part 3 Use griddata to evaluate: Xwarpleft = griddata(CXright,CYright,CXleft,Xright,Yright, ‘cubic’); Ywarpleft = griddata(CXright,CYright,CYleft,Xright,Yright, ‘cubic’); where Xright and Yright are a rectangular grid of pixel locations in the right hand image, created with meshgrid. The output Xwarpleft and Ywarpleft indicate the coordinates in the left image where the color of each pixel in the final right image is going to be found Try using ‘linear’, ‘cubic’, ‘v4’ (i.e. first, third and mystery order interpolation) Make sure the calculated Xwarpleft and Ywarpleft are in bounds

13 MA/CS 37513 Part 4 For each pixel in the right picture, use the coordinates (Xwarpleft,Ywarpleft in the left picture) found in Part 3, and the function interp2 to find the three intensities (red, green and blue) in the left picture at the warped coordinates. Convert the results into unsigned 8-bit integers using uint8. Use image to plot the deformed picture.

14 MA/CS 37514 Example Green points map to red points  warped coordinate system

15 MA/CS 37515 Part 5 Using linear interpolation in time, plot a sequence of tween images (t=0,0.2,0.4,..,1) using: C(x,y) = LeftImage((1-t)*Xleft+t*Xwarpleft,(1-t)*Yleft+t*Ywarpleft) Where the values of LeftImage are obtained with interp2

16 MA/CS 37516 Example of Tweening

17 MA/CS 37517 Part 6 Using linear interpolation in time (t=0, 0.2, …, 1.0), plot a sequence of tween images using: C(x,y) = LeftImage((1-t)*Xleft+t*Xright,(1-t)*Yleft+t*Yright) THEN: Using linear interpolation in time (t=0, 0.2, …, 1.0), plot a sequence of tween images using: C(x,y) = (1-t)*LeftImage(Xwarpleft,Ywarpleft)+t*RightImage(Xright,Yright)

18 MA/CS 37518 Part 7 Each team member should contribute a picture. Using the same method as Part 6 create an animation of the pictures morphing from one to the other in sequence.

19 MA/CS 37519 Part 8 (extra credit) Create a graphical user interface for the project using guide It should have a number of buttons, sliders, radio buttons e.g. –a slider to choose the number of control points –a file option to choose the left and right images –an option to add and reduce control points –a zoom option –a slider to choose number of tween frames –…. Go wild….

20 MA/CS 37520 guide Type guide at the matlab prompt: Matlab functions http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/creating_guis.shtml

21 MA/CS 37521 guide cont (adding a slider) 1)click on slider icon 2)move mouse to top left of required slider 3)drag rectangle to specify shape of slider 4)click File, then save as (1) (2) (3)

22 MA/CS 37522 guide cont. (enabling a slider button) right click on slider button left click on properties you can now edit the properties of this slider

23 MA/CS 37523 Using handles > fig = openfig(mfilename,'reuse'); > handles = guihandles(fig); % Create structure for the first time > slider_value = get(handles.slider1, ‘Value);

24 MA/CS 37524 Add A Bunch of Options (but design a better interface)

25 MA/CS 37525 Running GUI:

26 MA/CS 37526 Checking slider value

27 MA/CS 37527 Project Due 10/23/02 No extensions. Presentations due on 10/23 I encourage you to get the majority of it working well before the due date !!. Each team member must submit their own report, preferably with experiments using their own pictures.


Download ppt "MA/CS 3751 Fall 2002 Lecture 24. MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image."

Similar presentations


Ads by Google