COMP1005 - Practical Test 2 Within your work area, create a PracTest2 directory to work in. 1. Download and modify a Python program Download the zip file from Blackboard/Assessments and put it in the PracTest2 directory. Unzip the file using the unzip command, then edit test2.py and imgfun.py as needed to satisfy the instructions below: Modify the code to: 1. Subplots for all images – update the code to: a. Cycle through the four images in a for-each loop b. Creating a 2x2 set of subplots for each of the images c. Add a suptitle, including the image name and set the fontsize=18 d. Save the plots to match the image name e.g. blackknight.png (1 mark) 2. Complete the function pixelate (in imgfun.py) to return a new image “pixelated” to the step value, entered by the user. Use this for the top left image, with a title that includes the pixelation factor (1 mark) 3. Create a new function called flipV(img) in imgfun.py which takes an image and flips it vertically. Place it in the top right subplot (1 mark) 4. Create a new function called notred(img) in imgfun.py which takes an image and removes (zeros) the red channel. (1/2 mark) 5. Create a new function called justred(img) in imgfun.py which takes an image and removes (zeros) all but the red channel. (1/2 mark) 2. README and history • • Record the history of the commands you’ve used: history > hist.txt Create or copy a README file and update it to include info on your code and images 3. Submission and Assessment Ask your tutor to assess your work when complete. All of your work should be submitted via Blackboard through the link on the Assessment page. This should be done as a single "zipped" file. zip –r PracTest2_ID PracTest2 End of Test Hints: • Familiarise yourself with the code before making changes – e.g. • • • imgfun.py is a module for functions to import into your program Look in the matplotlib documentation to find out how to do: o suptitle for the top title o plt.subplots(2,2,figsize=(10,10)) for overall figure size o plt.savefig for saving images These colour images are 3D numpy arrays, so you can use slicing on x/y OR rows/columns. The colour/intensity is the third dimension: red/green/blue: e.g. size (771,973,3) => rows, columns, colour Sample output is below – one set of subplots for each image: