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.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 and is described further in Problem 5.
You will do your work by modifying blur_image.py
and submitting the modified version. Add your name to the top of this file. Otherwise, there is no code to write for this problem.
Run 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
: be sure that you are using thecse160
environment. 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.
Note
We have intentionally provided the grid file with the .txt
extension instead of the more common .csv
so that you can easily open it within VSCode.
The .png
file can be opened in any image browser and should appear slightly blurred. The .txt
file can be examined to determine if you are performing blurring correctly.
The only thing you need to make sure at this point is that the file runs correctly and you get this output: