Skip to content

Commit

Permalink
gamma_transform optimization (#331)
Browse files Browse the repository at this point in the history
* gamma_transform optimization

* gamma_transform removed division
  • Loading branch information
Dipet authored and ternaus committed Sep 4, 2019
1 parent 448761d commit ac499d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit ac499d0

Please sign in to comment.