Obtain the files, add your name¶
Download the starter code for this assignment. Then, extract (unzip) the contents anywhere on your computer. In VSCode, navigate to File | Open Folder and select the homework3
folder. Inside the homework3
folder you’ll find a number of files:
blur_image.py
: a partial Python program that you will complete.utils.py
: a collection of functions to help build the program. While it could be educational to read through and understand the functions in here, you are not expected to.images
: a directory which contains some sample black and white images for you to process.test_grids
: a directory which contains some very small sample black and white images stored as text files in CSV (comma-separated values) format.color_to_gray.py
: a Python program that will convert color images into black and white images. This program is optional for you to use in converting your own images to black and white images. This is described further in Problem 5.test_blur_image.py
: a Python program to test and partially validate that yourblur_image.py
program produces expected results. While passing all of the tests from this program (i.e., if you see the “All tests passed!” message after running) is a strong indication of having completed everything for this assignment, it is not a guarantee of a full grade. See more details in the full assignment specification.
You will do your work by modifying blur_image.py
and submitting the modified version. This is the only file that we expect you to submit.
Running the program¶
Similar to Homework 2, for this assignment you will run your program in the terminal in VSCode. Open blur_image.py
and open the terminal (Terminal | New Terminal or Ctrl+Shift+`). You can run the program by typing in the following command:
- On Mac/Linux:
python blur_image.py images/Husky.png
- On Windows:
python blur_image.py images\Husky.png
Info
If you are on Mac and this command doesn’t work, you might need to type in python3
instead of python
to run it correctly.
Possible Errors
can't open file 'Husky.png'
orNo such file or directory
: double check that you opened thehomework3
folder in VSCode and that you typed the name of the file correctlyImportError: No module name Image
orModuleNotFoundError: No module named 'PIL'
: be sure that you are using thecse160
environment from Anaconda. Check Homework 0’s setup instructions to re-confirm.
Once you have finished the assignment, you will also see two newly created files in the current directory:
Husky_blurry.png:
a blurred version of the original Husky.pngHusky_blurry_grid.txt:
a text file containing the integer contents of the blurred grid. The integers are in CSV (comma separated value). This file will be useful for debugging your program.
If you haven’t yet completed the assignment, you will NOT see these files.
The .png
file can be opened in any image browser and should appear slightly blurred.
The only thing you need to make sure at this point is that the file runs correctly and you get this output: