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)

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question
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
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():
9.
'''Controls the program'"
fname
"https://runestone.academy/runestone/books/published/Studi
image. Image(fname)
img.getWidth()
img.getHeight()
image. ImageWin(width, height)
10
11
img
12
width
%3D
13
height
14
win =
modify(img, 0.5)
img.draw(win)
15
16
17
18 main() #Run the program
19
Activity: 1 ActiveCode (csw_modifybrightness)
Transcribed Image Text: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 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(): 9. '''Controls the program'" fname "https://runestone.academy/runestone/books/published/Studi image. Image(fname) img.getWidth() img.getHeight() image. ImageWin(width, height) 10 11 img 12 width %3D 13 height 14 win = modify(img, 0.5) img.draw(win) 15 16 17 18 main() #Run the program 19 Activity: 1 ActiveCode (csw_modifybrightness)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 6 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,