Answered step by step
Verified Expert Solution
Question
1 Approved Answer
It is a python program. Make sure it work in shell IDLE. Screenshot the code and output. 14. Write a program that converts a color
It is a python program. Make sure it work in shell IDLE. Screenshot the code and output.
14. Write a program that converts a color image to grayscale. The user supplies the name of a file containing a GIF or PPM image, and the program loads the image and displays the file. At the click of the mouse, the program converts the image to grayscale. The user is then prompted for a file name to store the grayscale image in. You will probably want to go back and review the Image object fro m the graphics library (Section 4.8.4). The basic idea for converting the image is to go through it pixel by pixel and convert each one from color to an appropriate ade of gray. A gray pixel is created by setting its red, green, and blue components to have the same brightness. So color 0, 0, 0) is black, color_rgb(255, 255, 255) is white, and color_rgbl 127, 127, 127) is a gray "halfway" between. You should use a weighted average of the original RGB values to determine the brightness of the gray. Here is the pseudocode for the grayscale algorithm _rgb( for each row in the image: for each col11mn in the image r, g, b get pixel information for current row and column brightness int(round(0.299r + 0.587g+ 0.1 14b) set pixel to color_rgb(brightness, brightness, brightness) update the image # to see progress row by row Note: The pixel operations in the Image class are rather slow, so you will want to use relatively small images (not 12 megapixels) to test your programStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started