CSS 501 Programming Assignment #3    



In this program, we are going to use recursion to create a type of image fractal. The image class you created for the previous program will be used with recursion in a non-trivial fashion to create a new image similar to the one below.


test       output



Using your image class, you should read in an image called “test.gif” and output an image called “output.gif.” You may change your image class if you want, but you should NOT write a class method that creates the fractal or shrinks the image. You should only use the accessor and mutator functions from your class for these operations. Your output should look like this:



Once again, you can use the image library at: ImageLib.lib and ImageLib.h

Here is another test image:                test.gif



Use the following specification exactly to get full credit.

output(r, c) = (input(2r, 2c) + input(2r+1, 2c) + input(2r, 2c+1) + input(2r+1, 2c+1) ) / 4

Always round down (integer division is fine).

output(r, c) = (input(maxR – 2r, maxC – 2c) + input(maxR – 2r – 1, maxC – 2c) +

input(maxR – 2r, maxC – 2c – 1) + input(maxR – 2r – 1, maxC – 2c – 1) ) / 4



There are (at least) two approaches to solving this correctly, although both use the recursion discussed above. In the first, the location of each of the recursive input and output images is maintained using careful bookkeeping without creating smaller images. In the second, each smaller quadrant is actually created as a separate (smaller) image and then they are stitched together. Either approach can achieve the correct result.


For additional fun

Create other interesting fractal patterns using recursion.



This program is worth 25% of the programming score for the course. See the grading rubric for a breakdown on how each program is scored.