Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python don't use built-in function Your tasks 1. Write a function bw(pixels, threshold) that takes the 2-D list pixels containing pixels for an image, and

Python don't use built-in function

image text in transcribed

image text in transcribed

Your tasks 1. Write a function bw(pixels, threshold) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list of pixels for an image that is a black-and-white version of the original image. The second input to the function is an integer threshold between 0 and 255, and it should govern which pixels are turned white and which are turned black. The brightness of a pixel [r,b,g] can be computed using this formula: 21r72g7b We've given you a helper function called brightnessO that you should use to make this computation. If a pixel's brightness (as determined by the brightnessO helper function) is greater than the specified threshold, the pixel should be turned white ([255,255,255]) otherwise, the pixel should be turned black ([0,0,0]). For example, if you do the following: pixelsload_pixelsC'spam.png bwspambw(pixels, 100) save_pixels(bw spam, 'bw spam.png') bw_spam.png saved you should obtain the following image: SPAM Your tasks 1. Write a function bw(pixels, threshold) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list of pixels for an image that is a black-and-white version of the original image. The second input to the function is an integer threshold between 0 and 255, and it should govern which pixels are turned white and which are turned black. The brightness of a pixel [r,b,g] can be computed using this formula: 21r72g7b We've given you a helper function called brightnessO that you should use to make this computation. If a pixel's brightness (as determined by the brightnessO helper function) is greater than the specified threshold, the pixel should be turned white ([255,255,255]) otherwise, the pixel should be turned black ([0,0,0]). For example, if you do the following: pixelsload_pixelsC'spam.png bwspambw(pixels, 100) save_pixels(bw spam, 'bw spam.png') bw_spam.png saved you should obtain the following image: SPAM

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

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

Describe ethics training.

Answered: 1 week ago

Question

What is management growth? What are its factors

Answered: 1 week ago