Initial commit with project files
This commit is contained in:
18
2_Bildbearbeitung/ü9/README.md
Normal file
18
2_Bildbearbeitung/ü9/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Übung 9: Gamma-Korrektur
|
||||
|
||||
In dieser Übung soll die Gamma-Korrektur
|
||||
|
||||
<p align="center">
|
||||
<img src="https://latex.codecogs.com/svg.image?g'(x,y)=\frac{255}{255^\gamma}\cdot&space;g(x,y)^\gamma" title="" />
|
||||
</p>
|
||||
|
||||
für die bessere Sichtbarkeit des Bilder
|
||||

|
||||
verwendet werden.
|
||||
|
||||
Wenden Sie die Gamma Korrektur mit den Gamma-Werte 0.5,1 und 2 auf das Bild an, indem Sie ein Skript in die Datei [a.py](a.py)
|
||||
programmieren. Die Lösung ist in der Datei [l_a.py](l_a.py) zu finden!
|
||||
|
||||
|
||||
|
||||
|
||||
11
2_Bildbearbeitung/ü9/a.py
Normal file
11
2_Bildbearbeitung/ü9/a.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
img = cv2.imread("../../data/car.png")
|
||||
img = cv2.resize(img, (500, 500))
|
||||
cv2.imshow("Original", img)
|
||||
|
||||
|
||||
cv2.waitKey(0)
|
||||
|
||||
|
||||
21
2_Bildbearbeitung/ü9/l_a.py
Normal file
21
2_Bildbearbeitung/ü9/l_a.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
img = cv2.imread("../../data/car.png")
|
||||
img = cv2.resize(img, (500, 500))
|
||||
cv2.imshow("Original", img)
|
||||
|
||||
|
||||
def gamma_correction(img, gamma):
|
||||
img = img.astype(np.float)
|
||||
img = 255 * np.power(img, gamma) / np.power(255, gamma)
|
||||
print(np.max(img))
|
||||
img = img.astype(np.uint8)
|
||||
return img
|
||||
|
||||
|
||||
for gamma in [0.5, 1, 2]:
|
||||
cv2.imshow("%s" % gamma, gamma_correction(img, gamma))
|
||||
|
||||
cv2.waitKey(0)
|
||||
|
||||
Reference in New Issue
Block a user