First, you will be implementing the invert function. (Reminder: all of these functions take in a three-dimensional list, and return a three-dimensional list: it's up to you whether to create a new list or alter the original). This function performs a color inversion, as though you were producing a negative of a photo. Recall that each color component in every pixel is an integer between 0 and 255, inclusive. In every pixel, for each of the three color components, if the original value for the component was x, to invert the color you must set it to 255-X.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In python

First, you will be implementing the invert function.
(Reminder: all of these functions take in a
three-dimensional list, and return a three-dimensional list:
it's up to you whether to create a new list or alter the
original). This function performs a color inversion, as
though you were producing a negative of a photo. Recall
that each color component in every pixel is an integer
between 0 and 255, inclusive. In every pixel, for each of
the three color components, if the original value for the
component was x, to invert the color you must set it to
255-X.
Hint:
Go look at the swap_red_blue example near the
bottom of your hw06.py template if you're uns
unsure
how to loop through the pixels and access specific
colors at each pixel.
Examples:
>>> invert([[[127, 127, 127], [0, 0, 0]],
[[255, 255, 0], [50, 128, 255]],
[[0, 0, 255], [0, 255, 0]],
[[255, 0, 0], [255, 255, 255]]])
[[[128, 128, 128], [255, 255, 255]],
[[0, 0, 255], [205, 127, 0]],
[[255, 255, 0], [255, 0, 255]],
[0, 255, 255], [0, 0, 0]]]
>>> invert([[[36, 155, 90], [63, 208,
208], [151, 3, 14]],
[[53, 204, 53], [99, 103, 10], [94, 138,
216]]])
[[[219, 100, 165], [192, 47, 47], [104,
252, 241]],
[[202, 51, 202], [156, 152, 245], [161,
117, 39]]]
(note that the highlighting and the new line for each row
are for clarity purposes only and will not be present in the
actual console output, but the numbers should be correct)
Transcribed Image Text:First, you will be implementing the invert function. (Reminder: all of these functions take in a three-dimensional list, and return a three-dimensional list: it's up to you whether to create a new list or alter the original). This function performs a color inversion, as though you were producing a negative of a photo. Recall that each color component in every pixel is an integer between 0 and 255, inclusive. In every pixel, for each of the three color components, if the original value for the component was x, to invert the color you must set it to 255-X. Hint: Go look at the swap_red_blue example near the bottom of your hw06.py template if you're uns unsure how to loop through the pixels and access specific colors at each pixel. Examples: >>> invert([[[127, 127, 127], [0, 0, 0]], [[255, 255, 0], [50, 128, 255]], [[0, 0, 255], [0, 255, 0]], [[255, 0, 0], [255, 255, 255]]]) [[[128, 128, 128], [255, 255, 255]], [[0, 0, 255], [205, 127, 0]], [[255, 255, 0], [255, 0, 255]], [0, 255, 255], [0, 0, 0]]] >>> invert([[[36, 155, 90], [63, 208, 208], [151, 3, 14]], [[53, 204, 53], [99, 103, 10], [94, 138, 216]]]) [[[219, 100, 165], [192, 47, 47], [104, 252, 241]], [[202, 51, 202], [156, 152, 245], [161, 117, 39]]] (note that the highlighting and the new line for each row are for clarity purposes only and will not be present in the actual console output, but the numbers should be correct)
>>> transform_image('dice.bmp', 'invert')
transform_image('cat.bmp', 'invert')
>>>
>>>
transform_image('connector.bmp','invert')
12
8
20
8
12
dice.bmp
ol
20
invert_dice.bmp
8
8
6.
6.
(source: https://en.wikipedia.org/wiki/Dice)
cat.bmp
invert_cat.bmp
Transcribed Image Text:>>> transform_image('dice.bmp', 'invert') transform_image('cat.bmp', 'invert') >>> >>> transform_image('connector.bmp','invert') 12 8 20 8 12 dice.bmp ol 20 invert_dice.bmp 8 8 6. 6. (source: https://en.wikipedia.org/wiki/Dice) cat.bmp invert_cat.bmp
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY