$29
Introduction
Occasionally we can see some artistic drawings are actually drawn by alphabets. It is even more interesting if we can generate a large image that is composed of alphabets. In this assignment, you will be asked to write such a program so as to convert an existing image into a drawing that is formed with ASCII characters (ASCII art).
Assignment Details
1. You are required to implement an ANSI C / C++ program that can turn image into ASCII art.
2. Your program should be run under a command line environment in Windows 7 like the following format :
ascii inputfile.ppm outputfile.txt
3. “inputfile” is the full path to input image file, e.g “../input.ppm” or “d:\input.txt”. This image is in ppm format. Similarly, “outputfile” indicates the full path to output file.
4. The sample input and output are given for basic part only. We will use program to check whether your program output is exactly the same as ours for basic part. For bonus part, we will grade by hand.
5. The size of input image is not fixed but for better viewing we suggest images no larger than 100x100.
6. The reading routines of PPM image file format is provided, so we will not introduce the format of PPM in detail.
7. The detail of ASCII art is given in the next section.
Implementation Details
In ppm image, there are 3 channels(R, G, B) and each of them has 0-255 integral levels.
Suppose you are given a picture like this:
We need first turn it into gray scale images like this:
We can do this via the formula gray value = 0.299 * R + 0.587 * G + 0.114 * B.
After quantization and mapped to ASCII characters, you will be able to get something like this:
For basic part, you are required to quantize the gray value into 10 levels and mapped to {'#', '$', 'O', '=', '+', '|', '-', '^', '.', ' '} from high gray value to low gray value respectively. Since we use program to check the output, so here we explicitly require that use “\r\n” to start a new line and final value = floor(gray value / (255/10)), and special handle that if final value = 10, we also map it to ' ' the same as final value = 9. (Someone may argue that 255 should be 256 and some other issues but here we just want to simplify the basic part.)
For bonus part, you can use your own mapping character set, or modify the program so it can accept one more argument so that you can control how many levels you want to quantize, or you can find some more images which are more suitable for ASCII art, or modify the program so it will resize the input image to a suitable scale. You can even read the paper in http://www.cse.cuhk.edu.hk/~ttwong/papers/asciiart/asciiart.html and try to implement some features of it. If you can implement the method and show some demonstrative result, you will surely get a very high mark. All these features will add up to the bonus part. You should also write a txt, doc or docx to tell us how many features you have implement and how to run the code to see the improvements. The features implemented should really improve the ASCII art generating, and the txt is for you to show the improvements.
Guidelines to submit programming assignments
1. In all your source files, type your full name and student ID.
2. You are required to write your programs using ANSI C/C++ language, since this will allow your code to be compatible for compilers on different platform.
3. Provide one source file and name it as "ascii.cpp" and its exe file “ascii.exe” for basic part. Provide another source file and name it as "ascii_bonus.cpp" and its exe file “ascii_bonus.exe” for bonus part. Put all images in folder "image".
4. Use zip to pack the source files ascii.cpp, ascii_bonus.cpp, executable files ascii.exe, ascii_bonus.exe and the directory image. Name the zip file with your CWEM username, e.g s0123456789.zip
5. You are required to submit your homework though the elearning system. http://elearn.cuhk.edu.hk
Marking Schemes
Basic part
100%
Bonus part
10%
Total
110%