Skip to content

Commit 9021fd0

Browse files
committed
fix sepia effect
1 parent bfb86dc commit 9021fd0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

adafruit_pycamera/imageprocessing.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ def do_solarize(channel):
213213

214214

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

226226

0 commit comments

Comments
 (0)