Starting from:

$29.99

Assignment 5_Building integrated software systems

 Assignment 5_Building integrated software systems
1 Pedagogical objectives
Implement a larger software system that includes components from the web, C libraries written by others, as well as your own code written in Python in order to produce a functional integrated system.
2 Background - Image Filtering
A common operation in graphics and video production is to apply a so-called filter to an image through the process of convolution. We are considering convolution because it easily shows the differences in efficiency between languages and implementations. For example, a code sample convolve slow.py can be found in COMP206 A5 provided.tar.gz, and compared with the convert built-in we have used during A1. Both apply a Laplacian filter to find edges in an image, but the built-in function is over 100 times faster:
utah.bmp utah edges.bmp
You are not responsible for the finer details of convolution, you must just have a basic understanding, and be able to work with some existing code that performs the operation. However, it will probably be useful to read some background at: http://en.wikipedia.org/wiki/Kernel_(image_processing).
1
3 Problems
3.1 Simple filtering (30 marks)
Filters an image by connecting to the libfast filter.so C library provided, using ctypes. The header file, fast filter.h, gives the spec for this library. You can assume the library is located in the present working directory and that LD LIBRARY PATH has been set appropriately. The filtering process is controlled by the following command-line arguments: • The input image path • The output image path • The width of the square image filter, W, as one integer number • The filter weights as WxW floating point numbers
Your code must be written in q1 image filter.py, and should result in the same outputs as convolve slow.py, but should be much faster (50x speed-up is possible, but not required).
3.2 Filtering with command history (70 marks)
Extend the functionality in Q1 by adding a session history that allows undo and redo, similar to a text editor. Each call to the program implements one image operation, which is specified by the command-line arguments: • load input image path: loads the specified file, discards any existing history and makes this image the active image. • filter filter width filter weights (same argument format from Q1): applies the specified filter to the previously active image. The filtered result becomes the new active image and is placed at the next step in the history. Any previous history from this point forwards must be truncated. • undo: moves the active image backwards by one step in history, if this is possible.
2
• redo: moves the active image forwards by one step in history, if this is possible.
The active image must always be written to result.bmp in the present working directory. Whenever an operation cannot be completed properly, print a sensible message to standard output. In order to implement the history, only one additional file called history.pickle is allowed be used, and it must also be stored in the present working directory. Your code must be written as q2 filter with history.py.
3.3 Filter with web interface (50 marks)
Adapt your functionality from Q2 to form a Python CGI that runs on the SOCS web server in your student account. Use the html file A5Q3 template.html as the starting page for each session. Your code must run when the form on that page is submitted, and must dynamically generate a page with the same elements, forming a recursive CGI that allows filtering with history. Note that we will restrict the filter size to always be 3x3 for this question. Your code must be written as q3 cgi filter.py. It must be submitted to My Courses, and you must also have a working version of the page running at www.cs.mcgill.ca/~<yourusername/A5Q3_template.html. A sample of this functionality is located at http://www.cs.mcgill.ca/ ~dmeger/A5Q3_template.html, but note that it is not set up to handle multiple concurrent users. Please use it lightly to get the rough idea and then start to build your own solution.
4 Submitting
Create a single zip file, A5 solutions.zip that contains your 3 code files: q1 image filter.py, q2 filter with history.py and q3 cgi filter.py.

More products