Joseph Drackey

Generation

generate functionThu, 30 Mar 2023

Complete this program with a sharpen function that sharpens the edge of an image while keeping its original colors: from images import Image def main(): filename = input("Enter the image file name: ") image = Image(filename) newimage = sharpen(image, 20, 15) newimage.draw() if __name__ == "__main__": main()

def sharpen(image, max_x, max_y): newimage = Image(image.getWidth(), image.getHeight()) for y in range(image.getHeight()): for x in range(image.getWidth()): r, g, b = image.getPixel(x, y) if x > max_x and x < (image.getWidth() - max_x) and y > max_y and y < (image.getHeight() - max_y): newimage.setPixel(x, y, r, g, b) else: r = 255 g = 255 b = 255 newimage.setPixel(x, y, r, g, b) return newimage

Questions about programming?Chat with your personal AI assistant