# Assignment 2: Texture Synthesis

## CMSC 635, Due October 27, 2005

### Assignment

Choose a texture synthesis algorithm, either one described in one of the course papers, or another from a peer-reviewed conference or journal. Write your own implementation of your chosen algorithm and use it to generate a larger patch from one of each of the seven classes of images on www.cns.nyu.edu/~eero/texture: Artificial/periodic, Artificial/non-periodic, Photographic/pseudo-peridoic, Photographic/random, Photographic/structured, Inhomogeneous, and Color.

#### Image files

You will need to read and write image files for this assignment. Viable options are to use an image I/O library, or use your own code for a simple format like PPM. You need only support a single image format and can use an external tool to convert to and from your format (e.g. 'convert' on unix or an image editor like PhotoShop). Some common single-format external libraries include libgif, libtiff, libpng, or libjpeg. ImageMagick handles many image formats (though I never really liked its interface).

PPM files are a good choice for simple file I/O without resorting to an external library. To create a PPM file, first you should store your image in an array of bytes in y/x/color:

`unsigned char pixels[HEIGHT][WIDTH][3];`

When filling in this array, remember that it is in y/x order, not the more familiar x/y order. The final index is the color component, with r=0, g=1 and b=2. Color values range from 0 to 255. For example, this would store a floating point color value of .5 into the green component at x,y:

`pixels[y][x][1]= .5*255;`

Once you've filled in the pixels array, actually writing the PPM file is quite simple:

```FILE *f = fopen("file.ppm","wb");
fprintf(f, "P6\n%d %d\n%d\n", WIDTH, HEIGHT, 255);
fwrite(pixels, 1, HEIGHT*WIDTH*3, f);
fclose(f);```

### Show and tell

On November 1st, I'd like to spend just a couple of minutes each for you to show the best and worst of your synthesis results and tell the class about your experiences. Let me know in a README file in your submission which of your submitted files you'd like to show so I can have them loaded up and ready to go.

### What to turn in

Turn in a copy of each sample image you use and the patch generated from it, as well as your source and any additional files I'll need to build and run your project. You should also check in an informal one to two page write-up in a file named README in your assignment directory. While the write-up may be informal, I will count off for spelling and grammar. Please proofread before you turn it in. The write-up should describe what help you got, if any, what you did, how you did it, how well you think it worked, and what further work you might do. Include what hardware and software you used (it is not necessary to use the gl.umbc systems, though you must submit there), and what files you'd like to show at show and tell.

Turn in these files by checking them into the class CVS repository on gl.umbc 11:59 PM Thursday, October 27th.