From ac499d0365bfb2494cb535e82591fc3460d4595a Mon Sep 17 00:00:00 2001 From: Mikhail Druzhinin Date: Wed, 4 Sep 2019 19:58:11 +0300 Subject: [PATCH] gamma_transform optimization (#331) * gamma_transform optimization * gamma_transform removed division --- albumentations/augmentations/functional.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/albumentations/augmentations/functional.py b/albumentations/augmentations/functional.py index 157ad7fdc..3ef423ea5 100644 --- a/albumentations/augmentations/functional.py +++ b/albumentations/augmentations/functional.py @@ -1047,8 +1047,8 @@ def channel_dropout(img, channels_to_drop, fill_value=0): def gamma_transform(img, gamma): if img.dtype == np.uint8: invGamma = 1.0 / gamma - table = np.array([((i / 255.0) ** invGamma) * 255 for i in np.arange(0, 256)]).astype("uint8") - img = cv2.LUT(img, table) + table = (np.arange(0, 256.0 / 255, 1.0 / 255) ** invGamma) * 255 + img = cv2.LUT(img, table.astype(np.uint8)) else: img = np.power(img, gamma)