From 7f873afa85f395374e2a81f6c6ed17925ec73df4 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 18 Sep 2021 09:38:26 -0400 Subject: [PATCH] [+] a1 p4: maximize_channels and divide_channels --- assignments/a1/a1_part4.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assignments/a1/a1_part4.py b/assignments/a1/a1_part4.py index 2d3b572..fe18745 100755 --- a/assignments/a1/a1_part4.py +++ b/assignments/a1/a1_part4.py @@ -25,20 +25,26 @@ def maximize_channels(old_pixel: tuple, value: int) -> tuple: """Return a new pixel that has colour channels set to the larger of value or the corresponding colour channel in old_pixel. + * Assumed that value is positive + >>> example_pixel = (100, 12, 155) >>> maximize_channels(example_pixel, 128) (128, 128, 155) """ + return tuple([max(chan, value) for chan in old_pixel]) def divide_channels(old_pixel: tuple, denominator: int) -> tuple: """Return a new pixel that has colour channels set to the quotient from dividing the corresponding colour channel in old_pixel by denominator. + * Assumed that denominators are positive integers. + >>> example_pixel = (100, 12, 155) >>> divide_channels(example_pixel, 2) (50, 6, 77) """ + return tuple([chan // denominator for chan in old_pixel]) def add_pepper(pixel_data: list, k: int) -> list: