Skip to content

Commit

Permalink
fixed readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stheakanath committed Jan 4, 2016
1 parent 8a5c9d0 commit a54fce1
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 495 deletions.
46 changes: 10 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
Kuriakose Sony Theakanath
Face Morphing
README.md
# Face Morpher
Applying Delaunay triangulation and affline warping to face morph two pictures.

NOT COMPLETE.
![Mathurkuriakose](http://imgur.com/NTxSicO.gif)

================
Running the Code
================
python main.py <image1> <image2>

Note you'll need a dependency on cv2 for the some of the helper functions.

Also the selection of the points is dependent on the order. If you select the points in an incorrect order, you may not get a good morph!

The code will first ask you to select 60 points on the first image. Once you select all 60 points then you can hit the red bubble to move on. The second image that shows allows you to move the points so that you can select the defining features of the second image. Again, hit the red bubble (close button) to move on.

===================
Explanation of Code
===================
Now let's go through all of the functions in the readme. Note that this is in chronological order of how the functions are called when the user runs the code.

The main function in the code is selectPoints(im1_path, im2_path). selectPoints takes 2 images and shows the image using matplotlib. The user then has to select 60 points and then they can move on. Code wise you are selecting the defining features of the first person so that the triangulation formula will work correctly. The code then relays these same points on the second image and then the user can move the points based on the second person's features. The function that handles this call is:

drag_control_points(img, cpts). drag_control_points(img, cpts) then calls combinePoints(pt1, pt2) which combines both of the points selected by the user into a tuple array so that the actual algorithm can process it.
## Algorithm
The algorithm uses Delaunay's triangulation. To do this, we indiviually select points that match each other on both images. After doing this, triangles are automatically created such that the size of both don't exceed 45 degrees. This allows each individual triangle to be affline warped to the set of points that are changed. After we create our triangulation, we affline warp a certain amount, depending on how far we want our image to look like

interpolatePts(features) then takes the array containing all of the tuples and then creates a Delaunay triangulation using the cv2 API.

warpImage(orig, features, diang, src) is the the third function that is called after interpolatePts. warpImage takes the original image, the feature points created, the diagnoals that were returned by interpolatePts. warpImage then returns an image that is warped according to the triangles defined by the Delaunay triangulation formula.

def combineImages(features, diag, path1, path2) takes the warped image from the previous function and then creates 22 frames of how the image is being warped. We compute a ratio based on the magic number 22 and compute the warp based on that ratio.

After combineImages is called, we display it on the main screen and we are done!

Helper Functions Explanation
----------------------------
averageFace(path) - Average face takes a folder and returns the average face from the population. It adds all of the faces together and divides it by the amount of images in that certain folder.

exportShape(path) - Allows the user to select points on a defined image and then exports a .dat file so that the user can read it in again.
## Running Code
```
python main.py <image1> <image2>
```
Note you'll need a dependency on cv2 for the some of the helper functions. Both images also need to be of size 500 x 500 and the same size.
Binary file removed Website/images/LOL.jpg
Binary file not shown.
Binary file removed Website/images/average_brazil.png
Binary file not shown.
Binary file removed Website/images/mathuriakose.gif
Binary file not shown.
Binary file removed Website/images/midwayniksony.jpg
Binary file not shown.
Binary file removed Website/images/nik.jpg
Binary file not shown.
Binary file removed Website/images/obama.jpg
Binary file not shown.
Binary file removed Website/images/operson.gif
Binary file not shown.
Binary file removed Website/images/p1tomean.GIF
Binary file not shown.
Binary file removed Website/images/p2tomean.GIF
Binary file not shown.
Binary file removed Website/images/person.jpg
Binary file not shown.
Binary file removed Website/images/sony.jpg
Binary file not shown.
Binary file removed Website/images/sonymean.GIF
Binary file not shown.
103 changes: 0 additions & 103 deletions Website/index.html

This file was deleted.

Loading

0 comments on commit a54fce1

Please sign in to comment.