CS 351 Assignment #2: Fractals
Justin Russell & Adam Lowenstein
In this assignment, we created and altered a number of images. We started by defining the appropriate type structures and functions in C. These programs allowed us to produce and edit different types of images. Some of the images that we produced were generated from scratch, like the fractals created through the use of Mandelbrot and Julia sets. The program that we created to generate these images tested each pixel to see whether it was in the zero attractor (i.e., it was eventually going to zero) or the infinity attractor. The picture to the right was generated using the Julia set with an iteration limit of 100, meaning that if the number of iterations exceeded 100, the pixel was assumed to be going to infinity.
The other part of this assignment involved making a number of modifications to a photograph taken in front of a blue screen. These modifications included changing the background color, replacing the background color with a photograph of the same size, and replacing the background with a photograph of a different size. These operations are described in greater detail in the sections below.
Before we could begin generating images of the Mandelbrot and Julia sets, we needed to create the Image type structure in C. To do so, we created a function called Image_init() that takes two integer parameters, rows and columns, and allocates the corresponding space for an image. In Image_mandelbrot(), we used Image_init() to implement the Mandelbrot algorithm provided in the lab notes. By altering the variables and constants within the algorithm, we were able to create a number of different representations of the Mandelbrot and Julia sets.
In the second part of the lab, we took a picture of Adam that was taken in front of a blue screen replaced the background. First, we wrote a program that turned to black all of the blue pixels above a certain threshold of "blueness," so the image was set against a black background. Then, we replaced the black background and imported an image of the Wu-Tang Clan (R.I.P. ODB) as our new background
How we solved the the task
As mentioned earlier, the algorithm used to generate the Mandelbrot and Julia sets was based on the pseudocode provided in the lab notes. Our implementation of that algorithm, in conjunction with the Mandelbrot.c file (which contained a Main function to generate the image and specify its dimensions), allowed us to create a number of different images: