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
9import cv2 as cv
10import numpy as np
11
12
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 # ˄
A class for performing gamma correction on images.
gamma_correction(self, image)
Applies gamma correction to an image.
__init__(self, gamma)
Constructor for GammaCorrector.