Assignment 3A: Image Warping (or fun with frames)
Due Tues, March 30 (100 pts)
Images by THEfunkyman on flickr.com
Overview
In this assignment you will experiment with computing and applying image transformations using
matlab. Example input to your
method will be two file names denoting a target image (left), and source image (center). Output will be something
like the result image (right) where part of the source image has been warped to fit within the frame in the target image.
Part 1 (20 pts)
Implement a wrapper function, wrapper(targetfilename,sourcefilename,resultfilename), that
takes three file names as input: targetfilename specifies the target image (left), sourcefilename specifies the
source image (center), resultfilename specifies where to save the result (right).
This function should:
- Read in the target and source images.
- Ask the user to click on 4 points in each image. For the target image this specifies the rectangle
where you want to insert (ie the user might click on the four corners of the frame in the target image). For
the source image this specifies what you want to insert (ie the user should click on 4 points denoting what
rectangular piece to insert).
- Make these user specified points integers so that they can be used to index into images.
- Call the frameit function described next.
Useful matlab functions for this part are imread, ginput, floor, ceil, round. As always use help in matlab
to get descriptions of each function (or look them up on google).
Part 2 (65 pts)
Implement a function, frameit(targetimg,sourceimg,targetx,targety,sourcex,sourcey,resultfilename)
that takes as input the images read in by wrapper.m, the x, and y locations of the points clicked on by
the user for the source and target images, and the file name for where to save the resulting merged image.
This function should:
- Compute the best affine transform between the source and target points.
- Extract the piece of the source image that the user selected.
- Transform this piece according to the computed affine transform.
- Insert this transformed image into the target image in the rectangle specified by the user
- Display the resulting merged image.
- Save the resulting image as resultfilename.
Useful matlab functions for this part are cp2tform, imtransform, imresize, min, max. As always use help
in matlab to get descriptions of each function (or look them up on google).
Part 3 (15 pts)
Start with the example images I have provided:
Target Image, Source Image
to test out your code. Now, find or capture your own images, and play around with making interesting
combinations. You should run your code on at least 5 different pairs of images. Here points will be
given for inventiveness. Display your image triples (source, target, result) in a webpage, results.html.
What to turn in
- Your code for the functions described in Part 1 and 2: wrapper.m and frameit.m.
- A wepage called results.html, showing target image, source image, and result image for the
example images I provided, as well as for the images you collected or captured in Part 3.