Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

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

Algorithms & Pictures

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:

This is an image of the Mandlebrot set generated by setting the zero attractor pixels to display only blue pixels of low random intensity (yielding different shades of dark blue) and the infinity attractor pixels to random shades of green and blue.

This assignment taught us a great deal about how images actually are created and how colors can be altered to generate different effects. It's one thing to know how to use a program like Photoshop or Gimp, but it's much more important to understand the science between those programs. In addition to attaining this graphics knowledge, we gained a MUCH greater understanding of C as a result of this assignment, a skill that may be useful from time to time over the course of the semester.

  • No labels