12.19. 🤔 Image Processing Revisited

Image used under Creative Commons Attribution License.

Use the name “GoldenGateBridgeCC.png” to access this image.

Returning to the code that you wrote in the original image processing project. convert your grayscale algorithm into a function called grayscale that takes an image as a parameter and returns a new image that has been converted to grayscale, leaving the old image alone. Display the old image on the top of the window and the new image below.

Next convert your rotation and scaling algorithms into functions. Your rotation function should take two parameters, an image, and the number of degrees to rotate. If you only know how to rotate an image by 90, 180, or 270 degrees then you should check the parameters and print an error if it is not one of those values. If you are ready to tackle rotating by any number of degrees now would be a great time to do so. Your scaling function should take an image as a parameter along with a scale factor. Both of these functions should return a new image leaving the original alone.

Then use the functions together to take an image, rotate it by 90 degrees, enlarge it by a factor of 2 and convert it to gray scale.

Next design and write functions that will allow you to do:

Do the smoothing here using our old friend the noisyman.


noisyman.png

Do the edge detection here.

Write a function called montage that takes a background image and a foreground image and a row and column. The foreground image should be a green-backgrounded image so you can place it anywhere on the background image. The row and column parameters tell you where to put the foreground image in the background image.


ducky.jpg

A fun test for this and your other functions is to write a program that makes a row of small rubber ducks swimming in the bay under the golden gate bridge!

Post Project Questions

Next Section - 12.20. 🤔 Predicting Pizza Prices - Linear Regression