PBL4_2
Loading...
Searching...
No Matches
gammaCorrector.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
8
9
import
cv2
as
cv
10
import
numpy
as
np
11
12
16
class
GammaCorrector
:
17
# ˅
18
19
# ˄
20
21
26
def
__init__
(self, gamma):
27
# ˅
28
self.
gamma
= gamma
29
# ˄
30
31
37
def
gamma_correction
(self, image):
38
# ˅
39
# Create a lookup table for gamma correction.
40
lut = np.array([((i / 255.0) ** (1 / self.
gamma
)) * 255
for
i
in
np.arange(256)]).astype(np.uint8)
41
# Apply the gamma correction using OpenCV's LUT function.
42
return
cv.LUT(image, lut)
43
# ˄
44
45
# ˅
46
47
# ˄
gammaCorrector.GammaCorrector
A class for performing gamma correction on images.
Definition
gammaCorrector.py:16
gammaCorrector.GammaCorrector.gamma
gamma
Definition
gammaCorrector.py:28
gammaCorrector.GammaCorrector.gamma_correction
gamma_correction(self, image)
Applies gamma correction to an image.
Definition
gammaCorrector.py:37
gammaCorrector.GammaCorrector.__init__
__init__(self, gamma)
Constructor for GammaCorrector.
Definition
gammaCorrector.py:26
Generated by
1.9.8