CS129 Project 4: Image Quilting for Texture Synthesis and Transfer

Reese Kuppig (rkuppig)

This algorithm implements an image-based method for texture synthesis and transfer. In texture synthesis, samples from a texture swatch are quilted together to form a similar texture with different dimensions. In texture transfer, samples from a texture swatch are mapped onto a black-and-white image (intensity image) and quilted together to form a textured version of the black-and-white image.


Algorithm

In both algorithms, square patches are densely sampled from the texture swatch and assembled in scanline order to form the final image. Each patch overlaps previous patches by a predefined margin, which allows for blending along the patch seams later. To select the next texture patch to quilt into the image, each candidate patch is scored on the SSD between the candidate patch overlap region and the overlap regions to the left and above the patch in the quilted image. The texture transfer algorithm imposes additional constraints, which will be discussed below. The outline of the texture synthesis algorithm is given now:

In the texture transfer algorithm, candidate patches were judged not only by how well they matched the existing image pixels, but also by how well they matched the given intensity image. Therefore, additional constraints were imposed in selecting the texture patch candidates. Also, since after the first iteration, the algorithm operates on a full quilted image, pixel differences are calculated not only in the overlap regions, but over the entire texture patch area. The relative weighting of pixel differences and intensity differences was given by a value alpha. At first, the alpha value strongly favored the intensity differences, creating a base layer of tones. With each iteration, the texture patch size decreased and the alpha value shifted more in favor of pixel differences, emphasizing patches that quilted together seamlessly. The outline of the texture transfer algorithm:

Extra Credit

To enable a dense search of texture patches, it was necessary to optimize the SSD calculations. This was achieved by implementing the calculations as a combination of filtering operations. Observing that A2 - B2 = A2 - 2AB + B2, it is possible to calculate each individual term of the right side of the equation as a filtering operation, and moreover, it is possible to calculate the sum of each term in the patch area as part of the same filtering step. The calculation of each term only takes into account the pixels that are to be compared, by using a mask that highlights the pixels under consideration.


Results

Texture Synthesis Results

The results of the texture synthesis algorithm are displayed below. The original texture swatch is shown to the left. To the right, a texture synthesized from random patches is shown first, followed by the results of the pixel-difference SSD scoring calculation, and finally the fully synthesized texture with seam carving. The results of the texture transfer algorithm are presented after.

Limitations: Due to the enforcement of random candidate selection, sometimes the selected patch is misaligned with the rest of the texture, and its misalignment cascades to the subsequent patch alignments. Additionally, the algorithm seems to be disrupted by coarse textures, so the patch size and the texture coarseness must complement each other.

apples.png

apples_random.png

apples_ssd.png

apples_min_cut.png

bark.jpg

bark_random.png

bark_ssd.png

bark_min_cut.png

brick.jpg

brick_random.png

brick_ssd.png

brick_min_cut.png

grass.jpg

grass_random.png

grass_ssd.png

grass_min_cut.png

gravel.jpg

gravel_random.png

gravel_ssd.png

gravel_min_cut.png

knit.jpg

knit_random.png

knit_ssd.png

knit_min_cut.png

plaid.jpg

plaid_random.png

plaid_ssd.png

plaid_min_cut.png

radishes.jpg

radishes_random.png

radishes_ssd.png

radishes_min_cut.png

random.png

random_random.png

random_ssd.png

random_min_cut.png

random3.png

random3_random.png

random3_ssd.png

random3_min_cut.png

rice.bmp

rice_random.png

rice_ssd.png

rice_min_cut.png

text.jpg

text_random.png

text_ssd.png

text_min_cut.png

toast.png

toast_random.png

toast_ssd.png

toast_min_cut.png

weave.jpg

weave_random.png

weave_ssd.png

weave_min_cut.png

Texture Transfer Results

The results of the texture transfer algorithm are shown below. In the top left is the intensity image, and below that is the same image mapped with toast texture. The toast texture is shown for each intensity image, as it performed the most consistently for all images. In the top right is a separate texture swatch, and below that, the intensity image mapped with the different texture.

Limitations: The algorithm requires that the input texture has a good grayscale distribution, otherwise the results will be poor, and many textures will be repeated in the final image. These effects are especially prominent in areas of consistent intensity. To combat these problems, I tried to normalize the intensity values of the intensity images and the texture images.

al.jpg random.png
altoast.png alrandom.png
ml.jpg concrete.jpg
mltoast.png mlconcrete.png
einstein.jpg moon.jpg
einsteintoast.png einsteinmoon.png
kissing.jpg tissue.jpg
kisstoast.png kisstissue.png
jobs.jpg circuit.jpg
jobstoast.png jobscircuit.png