Download the Medialib ex11 files from the gallery.
Exercise 1: Image Processing
Load and draw each pixel of a full color .ppm (Portable Pixel Map) image, and show the RGB histograms of the image using the rect() function of MediaLib to draw each vertical bar.
Convert the color image to a grayscale image using the following formula and save it to a .pgm (Portable Gray Map) file: Gray = 0.299 * Red + 0.587 * Green + 0.114 * Blue
Load and draw each pixel of the grayscale image and show its RGB histograms
Apply a 3x3 median filter to the grayscale image and save it to a .pgm file. The median filter is a non-linear digital filtering technique, often used to remove noise from an image or signal. Use the median() function of statistics module to get the median out of a list. Note: The median filter cannot be applied to the first/last row and the first/last column. Simply fill in the first/last row and the first/last column with 0s or 255s (black or white).
Load and draw the filtered grayscale image and show its RGB histograms
Exercise 2: Pizza Game
Design and develop the user interface and user interaction that can let the user to make a pizza simply with mouse clicks. For example:
Show two pizza images for the user to select
Show the selected pizza base and the images of materials
When the user click the material, it will be selected
When use click on the pizza base, draw the image of the material at the position of the mouse click
It is not necessary to follow the example. You may design a more interesting game.
An example of simple mouse interaction for the selection from two pizzas is given in the code file “final_ex2.py”. However, this can be refined so that:
When the mouse click is out of the pizza, the material should not be drawn.
The mouse click position is the center (instead of the top-left point) of the material image to draw.