Difference between revisions of "CSC111 Lab 7 Solutions 2014"
(→Solution Programs/Functions) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:40, 10 March 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:40, 10 March 2014 (EDT) | ||
---- | ---- | ||
+ | <onlydft> | ||
+ | |||
=Solution Programs/Functions= | =Solution Programs/Functions= | ||
Line 75: | Line 77: | ||
setColor( pixel, newColor ) | setColor( pixel, newColor ) | ||
return image | return image | ||
+ | |||
+ | # saturate(): transforms component into min or max value | ||
+ | # depending on its intensity. | ||
+ | def saturate( component ): | ||
+ | if component < 125: | ||
+ | component = 0 | ||
+ | else: | ||
+ | component = 255 | ||
+ | return component | ||
+ | |||
# AndyWarhol( image ): saturates the image by saturating the | # AndyWarhol( image ): saturates the image by saturating the | ||
Line 90: | Line 102: | ||
# the line below replaces the pixel with its original color. Change | # the line below replaces the pixel with its original color. Change | ||
# the amount of red, green and blue to see some change in the colors | # the amount of red, green and blue to see some change in the colors | ||
− | + | ||
− | + | newColor = makeColor( saturate(red), saturate(green), saturate(blue) ) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | newColor = makeColor( red, green, blue ) | ||
setColor( pixel, newColor ) | setColor( pixel, newColor ) | ||
return image | return image | ||
Line 185: | Line 186: | ||
+ | </onlydft> | ||
<br /> | <br /> |