Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming Assignment for Computer Science Course: Image Labeling Program - Prof. D. Grie, Quizzes of Computer Science

A programming assignment for a computer science course at the university of toronto. The assignment involves creating an image labeling program where a player can match terms to parts of a picture. The program reads in data from a file, topics.txt, to draw lines and labels on the picture. The assignment requires interaction with a gui and keeping track of lines and terms for each topic. The program is to be written in java.

Typology: Quizzes

Pre 2010

Uploaded on 08/30/2009

koofers-user-psx
koofers-user-psx 🇺🇸

5

(1)

10 documents

1 / 4

Toggle sidebar

Related documents


Partial preview of the text

Download Programming Assignment for Computer Science Course: Image Labeling Program - Prof. D. Grie and more Quizzes Computer Science in PDF only on Docsity! A7. Quizit. CS1110 Fall 2008 Due date on the CMS Where this assignment came from. The first programming course in computer science at the University of Toronto has a similar assignment this fall; we took the idea and much of the text below from it. Thanks, Paul Gries, for your help! Their assignment does not have a GUI and is done using Python instead of Java. Partners. If you want to work with a partner, both of you should do what is necessary on the CMS several days before the submission deadline. It is dishonest and against academic integrity to split the work so that each does half of the work. You must work together. Time spent. When you submit this program, we will ask you to tell us how much time you spent. Please keep track of this. Overview. This assignment is quite different in nature from the previous ones. There is a fairly large program to complete, with more freedom in what you do than in other assignments. The assignment is designed to give you practice in the following areas: Program design Arrays and Vectors String manipulation Quizit. It's almost time for that animal bio quiz. Or was it the bridge architecture quiz? Either way, it's obviously time to procrastinate and write a program to help you study. Your program will show a picture like the one on the right, but with numbers instead of terms (e.g. "liver"), and the player will try to match up terms on the picture. Thus, the program you write will interact with the user --a player-- just like in a game. The player will be given a list of topics (each with a picture) to choose from. The player chooses a topic, and the GUI shows the picture with numbers as labels to various parts of the picture. The player can pick one of the numbers and guess the real term associated with the picture part for that number. After each guess, the GUI provides feedback about whether the guess was right or wrong. We provide a series of screenshots of this game being played. Please read that page carefully before you read any further! Also, you can play the game on the web, because we have made an applet of it. Click here or access it from the assignments page of the course website. Downloading files. From the course website, download file A7.zip and unzip it. It contains files A7.java, Item.java, A7GUI.java, A7Panel.java (which make up the program skeleton that we give you); two images files, shark.jpg and 076monkey.jpg; and file topics.txt, which contains the data that the program will read in. Put all files in a directory, open the .java files in DrJava, and compile. Input to the program. File topics.txt, located in the same directory as your program, contains the information used by the program to draw lines and labels. The file contains no blank lines and has the following structure: topic: topic-name file-name1 term1 x1 y1 x2 y2 term2 x1 y1 x2 y2 term3 x1 y1 x2 y2 ... topic: topic-name file-name1 term1 x1 y1 x2 y2 term2 x1 y1 x2 y2 ... Thus, the file is divided into "topic blocks": The first line of each block, starting with "topic:", gives the name of the topic (e.g. Shark) and the name of the file containing an image (e.g. shark.jpg). This image file should be in the directory with program. Each "term" line indicates the correct answer to a part of the image and contains the coordinates of the lines from that point. The first pair, (x1, y1), represents the point closest to the actual picture (and thus farthest from the term); the second pair (x2, y2) is the other endpoint of the line (closest to the term). For the examples in this handout, we used this topics.txt file; the image files are shark.jpg. and 076monkey.jpg. Image 076monkey.jpg is a modified version of an image on website www.infovisual.info/02/076_en.html. Gries has written to infovisual.info to ask for permission to use the image this way and to tell them about the assignment --the resulting program might be a neat interactive addition to their website. Their reply was that they were thinking of adding this feature to their wesbite in 2009 and they wanted more information on how we did it. The website has hundreds of images for different topics. Overview of communication between GUI and your code in A7. All the code you will write goes in file A7.java. The program is started either by using it as an application by executing A7.main(null); or by visiting a webpage that has it included as an applet. We will discuss bboth applications and applets later. In either case, file topics.txt is read in and stored and an instance of the GUI class is created and shown, with the topics filled in. When the player chooses a topic and clicks button topic, the GUI calls an A7 procedure that does two things: (1) Retrieve the information for the topic from file inputFile ---the topic image and the labeling information for the image--- so that it can then draw the appropriate lines and numbers before displaying the image. In the next section, we discuss how this information is kept in a "dictionary" of items. (2) Call a procedure of the GUI to initialize the drop-down list of topics. When the player clicks button OK, the GUI calls an A7 procedure to process the player's association of a number and a term. This requires two things to be done: (1) Update the item given by the number with the player's choice of a term and (2) if the choice was correct, call the GUI to remove the number and the term from the drop-down lists. Keeping track of information: a dictionary. For a topic, your program need to keep track of the lines. To do this, use the coordinate pairs (x1, y1) and (x2, y2) found in topics.txt. Here's the spiracle coordinate pair for the shark picture: (187, 180) (177, 131). The first point (x1, y1) is the point on the picture, not the coordinates next to the label. The lines will be drawn on the image by your program whenever the picture is displayed. (What is a spiracle?) For each line, your program will also maintain the correct term, the number associated with the term, and the player's guess at the term ("" if none guessed yet). We suggest that your program use class Item to contain the information for one line. We give you a skeleton for class Item. It need fields for: The points: (x1, y1) and (x2, y2) The correct term The player's guess at this term ("" if they haven't guessed this term yet) The number of this line The Items for the current topic can be kept in Vector items. When a topic is chosen, a method in A7 will build this dictionary from the information that is in Vector inputFile. This dictionary satisfy the following: the items are ordered by the points (x1, y1) and (x2, y2). For example, if items b and c satisfy b.x1 < c.x1, then item b comes before c in inputFile, and if b.x1 = c.x1 and b.y1 < c.y1, b comes before c. The number of each item is based on its placement in field items after the items have been sorted by their points. Thus, the first item in items has number 0, the second number 1, etc. You may maintain the points any way you wish. Two obvious choices are: (1) use four int variables and (2) use two instances of class java.awt.Point. Here is the dictionary for the shark topic. Each line gives the information in an instance of class Item: (87, 188), (75, 181), 'Snout', '', '0' (113, 192), (99, 160), 'Nostril', '', '1' (128, 221), (108, 247), 'Mouth', '', '2' (146, 180), (127, 146),'Eye', '', '3' (187, 180), (177, 131), 'Spiracle', '', '4' (194, 229), (188, 289), 'Labial furrows', '', '5' (267, 242), (248, 312), 'Gill openings', '', '6' (412, 359), (435, 366), 'Pectoral fin', '', '7' (431, 110), (393, 87), 'Dorsal fin spine', '', '8' (479, 76), (466, 55), 'First dorsal fin', '', '9' (603, 293), (608, 310), 'Pelvic fin', '', '10' (664, 265), (724, 338), 'Clasper (males)', '', '11' (739, 141), (764, 108), 'Second dorsal fin', '', '12'
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved