Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python please File: testgrayscale.py Tests a function for converting a color image to grayscale from images import Image def grayscalefimage) Converts the argunent image to

image text in transcribed

python please

File: testgrayscale.py Tests a function for converting a color image to grayscale from images import Image def grayscalefimage) """Converts the argunent image to grayscale, tor ornsinuange( inage.getPixel (?.'yi for x in xrange (image.getWidthO getPixel return tuple of RGB values weight each component for human {r, r- g, b) int(r -image.getpixel(x, ?0.299) y) # perception lum = r + g + b inage.setPixel(x, y. Lum, lum, lum)) def main(filename "smokey.gif") image Image(filename print "close the image window to continue, image.araw) grayscaletimage) print "close the image windo to quit. image.draw) main() Write the following image processing programs: Copy the above testgrayscale.py program and modify it to perform a simplified gray-scaling calculation. For each pixel, calculate the average of the r. g. b values of the color image, and set all three r, g. b values to this average. Use the same main program to test your new function. Write a setColor function that expects two arguements: an image and an RGB tuple containing three integers. The setColor function should set every pixel in the image to the RGB tuple color. Test the setColor function from an interactive main program that creates a blank image that is 200 pixels wide by 100 pixels tall, allows the user to enter three integers for the RGB values, prints the prompt "Close the image window to continue", calls setColor with the image and the user specified color tuple, and draws the image

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago