In python, Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in the figures below. Original Sepia Original Image & Sepia Image Write and test a function named sepia that converts a color image to sepia. This function should first call grayscale to convert the color image to grayscale. A code segment for transforming the grayscale values to achieve a sepia effect follows.
In python,
Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in the figures below.
Original | Sepia |
---|---|
Original Image & Sepia Image
Write and test a function named sepia that converts a color image to sepia. This function should first call grayscale to convert the color image to grayscale. A code segment for transforming the grayscale values to achieve a sepia effect follows.
Note that the value for green does not change.
(red, green, blue) = image.getPixel(x, y)
if red < 63:
red = int(red * 1.1)
blue = int(blue * 0.9)
elif red < 192:
red = int(red * 1.15)
blue = int(blue * 0.85)
else:
red = min(int(red * 1.08), 255)
blue = int(blue * 0.
1. GUI TEST
2. CUSTOM TEST
3. IMAGE TEST
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images