When you do this, you should take all non-overlapping blocks in the image that you can. If we take a block that’s one one of the bricks, it’s somewhere in between, so the average is about middle gray, which ends up getting a lowercase c, which uses a medium amount of ink. If we take a dark region in the tree, the average is quite low, and it gets an uppercase B, which is one of the characters that uses the most ink. If we take a block in a bright region, the average grayscale is very high, so it ends up getting a single quote, which has very little ink. To see an example, let’s consider taking a block that’s 8 pixels tall and 4 pixels wide in different parts of an image of an Ursinus flag. In particular, we can average all of the grayscale values in a rectangular block that’s twice as tall as it is wide, and print out a single character for this block. To address both of these problems, we can output a single character per block of pixels. However, not only would this print out way too many characters, but the characters are only printed out half as wide as they are tall, so this would end up printing out an image that’s stretched out by a factor of 2 vertically (the “aspect ratio” would be wrong). Part 2: Rectangular AveragingĪt this point, we could simply print out a row of text for each row in the grayscale image, and print out the character at the index of GRAYSCALE_VALUES with the closest grayscale value. This indicates that a B is a darker character, with a grayscale value of only about 0.08. For instance, let’s run the following code, using the methods provided in the assignment: We usually treat the outer array index as a row (y coordinate) and the inner array index as a column (x coordinate). In this assignment, we will be dealing with grayscale images, in which each pixel goes from black (0) to white (1). Part 1: Grayscale Images and TextĪs we discussed in our 2D arrays module, a 2D array is a natural data structure for image data, since an image is a two dimensional object with both an x and y coordinate for each pixel. Please download the skeleton code for this assignment. In this assignment, we will restrict ourselves to characters in the ASCII subset of UTF-8, including lowercase letters, uppercase letters, and some special characters hence the name “ASCII Art.” An example is given below with the UC logo. Students will write a program to automatically generate “ASCII Art”, which is text that approximates a given image. In this assignment, you will work with with 2D arrays in Java with a concrete, visual application. Please refer to the following readings and examples offering templates to help get you started: To traverse and manipulate a 2-dimensional array.CS173: Intro to Computer Science - ASCII Art (100 Points) Assignment Goals
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |