76 lines
3.3 KiB
Markdown
76 lines
3.3 KiB
Markdown
|
In this assignment, you are asked to write a program that creates an image in
|
|||
|
ASCII PPM format.
|
|||
|
|
|||
|
Your program should accept, as a command line argument, the name of a file
|
|||
|
containing an "image description" (consisting of one line of text specifying the
|
|||
|
image height and image width, optionally followed other lines of text specifying
|
|||
|
any additional parameters your program might use), and it should generate a
|
|||
|
valid ASCII PPM file as output. The name of the output file should end with the
|
|||
|
suffix .ppm. Your program should be capable of accepting different input files
|
|||
|
and producing different output files without needing to be recompiled.
|
|||
|
|
|||
|
You are free to use whatever means you like to define the contents of the output
|
|||
|
image. If you have time and are so inclined, you can earn extra credit by doing
|
|||
|
something creative. Possibilities include: hardcoding an interesting pattern,
|
|||
|
generating a [procedural texture][1], generating an image of the [Mandelbrot
|
|||
|
set][2], or reading an image from a file and applying an interesting [filter][3]
|
|||
|
or function such as [line integral convolution][4]. Whatever approach you
|
|||
|
choose, the code you turn in **must** be your own.
|
|||
|
|
|||
|
[1]: https://en.wikipedia.org/wiki/Procedural_texture
|
|||
|
[2]: https://en.wikipedia.org/wiki/Mandelbrot_set
|
|||
|
[3]: https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|||
|
[4]: https://en.wikipedia.org/wiki/Line_integral_convolution
|
|||
|
|
|||
|
Detailed instructions:
|
|||
|
|
|||
|
1. Please use the following syntax to define the image size in your input file:
|
|||
|
|
|||
|
imsize width height
|
|||
|
|
|||
|
where imsize is a keyword and width and height are integers.
|
|||
|
|
|||
|
2. Please use the following syntax to define your output image:
|
|||
|
|
|||
|
P3
|
|||
|
|
|||
|
# any comments you want to include
|
|||
|
|
|||
|
width height
|
|||
|
|
|||
|
255
|
|||
|
|
|||
|
r(0,0) g(0,0) b(0,0) r(1,0) g(1,0) b(1,0) r(2,0) g(2,0) b(2,0) ...
|
|||
|
|
|||
|
Please note that in an ASCII PPM file, each pixel color is defined as an (r, g,
|
|||
|
b) triple, and the provided values are used to fill the image in row major
|
|||
|
order. Specifically, the first three entries represent the red, green and blue
|
|||
|
components of the color of the upper leftmost pixel in the image, the second
|
|||
|
three entries represent the color of the adjacent pixel to the right, and so on.
|
|||
|
|
|||
|
Your program will need to specify exactly one color triple for each pixel in
|
|||
|
your image. Try to keep the line length under 80 characters, or approximately
|
|||
|
4-5 pixels per line. It’s also okay to put each color component on its own line
|
|||
|
too. Do not insert any other characters such as commas, etc. between any of the
|
|||
|
color values.
|
|||
|
|
|||
|
You can use the free program [GIMP] to view your image, to verify that it looks
|
|||
|
the way you intend it to. GIMP is a general-purpose image editing tool that can
|
|||
|
also be used to convert images from multiple other formats into ASCII PPM format
|
|||
|
(and vice versa).
|
|||
|
|
|||
|
[gimp]: http://www.gimp.org
|
|||
|
|
|||
|
What you should turn in:
|
|||
|
|
|||
|
- a readme file that describes your what your program does
|
|||
|
- all of your source code, clearly commented
|
|||
|
- at least one ascii PPM image created by your program
|
|||
|
|
|||
|
We will plan to share the PPM images in class. If you would prefer that we not
|
|||
|
show your image, please let us know.
|
|||
|
|
|||
|
We will use this rubric: grading-criteria-0.pdf when grading your program. You
|
|||
|
are advised to check the rubric before beginning the assignment to fully
|
|||
|
understand how credit will be awarded.
|