# 45_average_image.py - #CSci 127 Teaching Staff #October...

• 2
• 83% (6) 5 out of 6 people found this document helpful

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 2 pages.

#CSci 127 Teaching Staff#October 2017#A program that summarizes images, like koalastothemax#Modified by:Yasmeen Roumieimport numpy as npimport matplotlib.pyplot as pltdef average(region):"""Takes a region of an image andReturns the average red, green, and blue values across the region."""red, green, blue = 0,0,0#<-- placeholder, can remove once defined.count = 0for i in len(region):for j in len(region[i]):count += 1red += region[i][j][0]green += region[i][j][1]blue += region[i][j][2]red, green, blue /= countreturn(red,green,blue)def setRegion(region, r,g,b):"""Takes a region of an image and red, green, and blue values, r, g, b.Sets the region so that all points havered values of r, green values of g, and blue values of b."""region[:,:,0] = rregion[:,:,1] = gregion[:,:,2] = b######################################################################### DO NOT CHANGE ANYTHING BELOW THIS LINE#########################################################################def quarter(img2, levels):"""
End of preview. Want to read all 2 pages?