image quilting

Synthesizing images by stitching together small patches. (Efros et al.).

Project: Textures and Seams

Logistics

Background

We will implement Image Quilting for Texture Synthesis and Transfer, a SIGGRAPH 2001 paper by Alexei A. Efros and William T. Freeman. The paper presents a simple image-based method to perform texture synthesis and texture transfer. Texture synthesis is the process of creating an image of arbitrary size from a small sample (grass sample above). Texture Transfer means re-redering an image in the style of another one (Abraham Lincoln above).

Requirements / Rubric

Extra Credit

The baseline will work reasonably well for many images, but for certain types of images there are very noticable failures. In particular, humans are very sensitive to distortions in faces and distortions in straight lines. Images with large areas of high-frequency texture also tend to behave oddly with simple energy functions.

Here are some ideas, but we will give credit for other clever ideas:

For all extra credit, be sure to demonstrate on in your report where your extra credit has improved image quality or created an interesting effect.

Hand in

You will lose points if you do not follow instructions. Every time after the first that you do not follow instructions, you will lose 5 points. The folder you hand in must contain the following:

To create the ZIP file to submit run:

>> createSubmissionZIP

from the MATLAB command line. Make sure you are in the current working directory in MATLAB, and that you keep the name writeup.pdf for your report. Upload the generated ZIP file to Gradescope.


Details

Texture Synthesis

The general idea of the presented texture synthesis method is to sample patches from the input texture and compose them in an overlapping way. The simplest solution would be to just randomly select a patch from the input texture each time. This is what the stencil code does. With this solution the overlapping regions are not likely to match and this will result in noticeable edges in the result. A better approach, which you will need to implement, is to find a patch in the input texture that has some agreement with the pixels in the overlapping region (e.g., small SSD error). This will already produce pretty good results but still has some unwanted edge artifacts. To get rid of those, your final implementation will try to find a minimum error cut for the overlapping region.

Figure 2 of the paper illustrates those 3 different methods:

The stencil code produces images as shown in (a). Your job will be to fill out the parts of get_patch_to_insert_synthesis.m that will produce results like in (b) and (c) in the above figure. You can run proj4_synthesis.m.

Texture Transfer

We can augment the texture synthesis approach above to get a texture transfer algorithm. That is re-rendering an image with the texture samples of a different image. Each sample patch that we add to our synthesized image must now respect two different constraints: (a) it should have some agreement with the already synthesized parts (this is the constraint we used in texture synthesis), and (b) it should have some correspondance with the image we want re-render. We will use a parameter \(\alpha\) to determine the tradeoff between these to constraints.

To come up with a term for part (b) we need some measurement of how much a patch agrees with the underlying image. We can do this by calculating the SSD of a patch and the image on some corresponding quantity. One such quantity could be image intensity or the blurred image intensity.

The paper suggest to run multiple iterations of this while decreasing the tile size and adjusting \(\alpha\) each time to get the best results. The stencil does that for you. If we run multiple iterations we will need to incorporate the agreement of a patch with the already synthesized image and not just with the overlap region. So the error term will end up being something like this:

error = (\(\alpha\)) * (overlap_error + previous_synthezised_error) + (\(1 - \alpha\)) * correspondence_error

Note that previous_synthezised_error will be 0 for the first iteration. Your code for this will go into get_matching_patch_transfer.m. You can run proj4_transfer.m.

Implementation Tips


Acknowledgements

Project derived from Image Quilting for Texture Synthesis and Transfer. Description and setup inspired by CS498 at University of Illinois at Urbana-Champaign. Some code taken from other projects of Brown CSCI 1290 or Brown CSCI 1430.