4. The following program loads and displays an image. Complete the modify function to change the brightness of the image. The parameter m is a multiplication factor. modify will will multiply each pixel by m - that means you need to multiply the red, green, and blue channels by m, create a new pixel with new red, green, and blue values, and replace the old pixel with the new pixel. Be sure none of the red, green, and blue values exceed 255 (if a value is greater than 255, set it to 255). Your program should work for images of any size. A good example is the sepia tone exercise. Do not change the main function, except to try different values for the multiplication factor. Save & Run Load History 1 import image 2 3 def modify(pic, m): ''Multiply each pixel by m to darken or brighten an image' pass #You can leave this or remove it #Your code here to change the brightness of the image 4 7 8 def main(): '''Controls the program''' fname = "https://runestone.academy/runestone/books/published/Stud img width = 10 image. Image(fname) img.getWidth() img.getHeight() 11 12 height win = image.ImageWin(width, height) modify(img, 0.5) img.draw(win) 13 14 15 16 17 18 main() #Run the program 19 Activity: 1 ActiveCode (csw_modifybrightness)
4. The following program loads and displays an image. Complete the modify function to change the brightness of the image. The parameter m is a multiplication factor. modify will will multiply each pixel by m - that means you need to multiply the red, green, and blue channels by m, create a new pixel with new red, green, and blue values, and replace the old pixel with the new pixel. Be sure none of the red, green, and blue values exceed 255 (if a value is greater than 255, set it to 255). Your program should work for images of any size. A good example is the sepia tone exercise. Do not change the main function, except to try different values for the multiplication factor. Save & Run Load History 1 import image 2 3 def modify(pic, m): ''Multiply each pixel by m to darken or brighten an image' pass #You can leave this or remove it #Your code here to change the brightness of the image 4 7 8 def main(): '''Controls the program''' fname = "https://runestone.academy/runestone/books/published/Stud img width = 10 image. Image(fname) img.getWidth() img.getHeight() 11 12 height win = image.ImageWin(width, height) modify(img, 0.5) img.draw(win) 13 14 15 16 17 18 main() #Run the program 19 Activity: 1 ActiveCode (csw_modifybrightness)
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 6 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,