Question: CMPUT 175 Use Python Write a program that blurs a part of image: 1.read the image from the provided gif file( goo.gl/jXyVWw ) 2.display the
CMPUT 175
Use Python Write a program that blurs a part of image:
1.read the image from the provided gif file(goo.gl/jXyVWw)
2.display the image in a window
3.ask the user to click on the image
4.pixelate an area of 200 *100 pixels centered on the mouse click coordinates
5.exit on an addition mouse click
Divide the pixelated area into squares of 10 *10 pixels, and replace each square with the average of the original colors of the pixels in that square. If the mouse click is too close to the boundary of the image, just ignore it and exit the program.
from cImage import *
def fill(image, x, y, newPixel): """ Fills a square of 10 by 10 pixels with top left corner at (x,y) with newPixel. """ pass
def average(image, x, y): """ Returns a Pixel with average RGB image intensities computed over a square of 10 by 10 pixels with top left corner at (x,y) """ pass
def blur(image, x, y): """ Pixelates an area of 200 by 100 pixels (20*10 by 10*10) with top left corner at (x,y) with squares 10 by 10 pixels""" for i in range(10): for j in range(20): # Take the average of the current 10*10 section, starting at (x,y) # new_pixel = average(...)
# Fill in each pixel in the 10*10 section with the new color # fill(..., new_pixel)
pass
def main(): file_name = "photo.gif"
# 1. Open a window displaying the image, with a width and height # equal to those of the image.
# 2. Determine the position of the mouse pointer, and if it is too close to # the edge of the boundary, ignore the click and exit.
# 3. As long as the coordinates are more than a given distance # from the boundary, blur the image.
# 4. Exit on a click
main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
