Skip to content

Commit

Permalink
fix sepia effect
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Jan 5, 2024
1 parent bfb86dc commit 9021fd0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions adafruit_pycamera/imageprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ def do_solarize(channel):


def sepia(bitmap):
"""Apply a sepia filter to an image in place
based on some coefficients I found on the internet"""
return bitmap_channel_filter3_inplace(
"""Apply a sepia filter to an image in place"""
r, g, b = bitmap_to_components_rgb565(bitmap)
luminance = np.right_shift(38 * r + 75 * g + 15 * b, 7)
return bitmap_from_components_inplace_rgb565(
bitmap,
lambda r, g, b: np.right_shift(50 * r + 98 * g + 24 * b, 7),
lambda r, g, b: np.right_shift(44 * r + 88 * g + 42 * b, 7),
lambda r, g, b: np.right_shift(35 * r + 69 * g + 17 * b, 7),
luminance,
np.right_shift(luminance * 113, 7),
np.right_shift(luminance * 88, 7),
)


Expand Down

0 comments on commit 9021fd0

Please sign in to comment.