Starting from:

$30

 Homework 5 NumPy array manipulation

 Homework 5
Instructions:
Submit your three Python scripts (hw5_p1.py, hw5_p2.py, and hw5_ p3.py) on CCLE due 5 PM,
Monday, 11/11/2019.
In this assignment, you will use NumPy array manipulation to perform simple image processing tasks.
Tasks:
Please refer to matplotlib image tutorial (http://matplotlib.org/users/image_tutorial.html)for loading,
viewing, and saving images. (That’s all you need from it.) All images for this assignment can be found in
the .zip file from which this document was extracted.
1. b.jpg was removed from the center (horizontal and vertical) of a.jpg. Use slicing to put the
image back together. Show the result on the screen and save it to c.jpg.
Name your script hw5_p1.py.
2. There are 9 differences between g.jpg and h.jpg. Use NumPy to reveal them by generating an
image like i.jpg (below), show it on your screen, and save it to i.jpg. If you are surprised by
the result of your initial attempt, check the data type of your arrays. What are the minimum and
maximum values? What happens when a calculation generates a result beyond these? What do
you need to happen and how can you get what you want? Do some experiments with a single
pixel to answer these questions and figure out what’s going wrong. You will need to perform
some data type conversions and other operations to get the desired result.
Name your script hw5_p2.py.
3. Replace the green background of e.jpg with a black background. It’s OK if there is a narrow
green “halo” surrounding the minion, but try to reduce it. Once you have that, try to place the
minion in d.jpg as shown in f.jpg below. Show the result on your screen and save it to your
own f.jpg. If you don’t get that far, just show the minion on a black background on your screen
and save that to f.jpg. Name your script hw5_p3.py.
i.jpg f.jpg

More products