Initial commit with project files
This commit is contained in:
22
2_Bildbearbeitung/ü6/README.md
Normal file
22
2_Bildbearbeitung/ü6/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Übung 6: Forward-Mapping / Backward-Mapping
|
||||
|
||||
In dieser Übung wird das *Forward-Mapping* und das *Backward-Mapping* bei geometrischen Transformationen betrachtet.
|
||||
Sie interessieren Sich für den Wert des Pixels an der Stelle **(x=12, y=38)** des Bildes
|
||||
|
||||
|
||||

|
||||
|
||||
nach der Transformation mit der Transformationsvorschrift
|
||||
|
||||
<p align="center">
|
||||
<img src="https://latex.codecogs.com/svg.image?\begin{pmatrix}&space;x'\\y'\end{pmatrix}&space;=\begin{pmatrix}&space;0.5&space;&&space;0\\0&space;&&space;0.5\end{pmatrix}\cdot\begin{pmatrix}&space;x\\y\end{pmatrix}.&space;" title="\begin{pmatrix} x'\\y'\end{pmatrix} =\begin{pmatrix} 0.5 & 0\\0 & 0.5\end{pmatrix}\cdot\begin{pmatrix} x\\y\end{pmatrix} ." />
|
||||
</p>
|
||||
|
||||
Berechnen Sie den Wert des Pixels an der Stelle **(x=12, y=38)** nach der Transformation unter Anwendung des Backward- und Forward-Mappings!
|
||||
|
||||
Schreiben Sie Ihr Skript in die Datei [a.py](a.py). Die Lösung ist in der Datei [l_a.py](l_a.py) zu finden!
|
||||
|
||||
|
||||
Vergleichen Sie Die Methoden: Wie unterscheiden Sie sich? Welche Vor- und Nachteile haben die Methoden?
|
||||
|
||||
|
||||
13
2_Bildbearbeitung/ü6/a.py
Normal file
13
2_Bildbearbeitung/ü6/a.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
img = cv2.imread("../../data/car.png")
|
||||
cv2.imshow("Car", img)
|
||||
|
||||
print("Image Shape:", img.shape)
|
||||
|
||||
print("\nForward-Mapping")
|
||||
|
||||
print("\nBackward-Mapping")
|
||||
|
||||
cv2.waitKey(0)
|
||||
29
2_Bildbearbeitung/ü6/l_a.py
Normal file
29
2_Bildbearbeitung/ü6/l_a.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
img = cv2.imread("../../data/car.png")
|
||||
cv2.imshow("Car", img)
|
||||
|
||||
print("Image Shape:", img.shape)
|
||||
|
||||
|
||||
print("\nForward-Mapping")
|
||||
new_image = np.zeros((int(img.shape[0] / 2), int(img.shape[1] / 2), img.shape[2]), dtype=np.uint8)
|
||||
|
||||
for x in range(img.shape[1]):
|
||||
for y in range(img.shape[0]):
|
||||
new_image[int(y/2), int(x/2)] = img[y, x]
|
||||
|
||||
cv2.imshow("Forward-Mapping", new_image)
|
||||
print("Pixel at position x=12, y=38", new_image[38, 12])
|
||||
|
||||
|
||||
print("\nBackward-Mapping")
|
||||
# Inverse Transformation:
|
||||
# (x, y)^T = ([2, 0] * (x', y')^T
|
||||
# [0, 2])
|
||||
|
||||
p_12_38 = img[38*2, 12*2]
|
||||
print("Pixel at position x=12, y=38", p_12_38)
|
||||
|
||||
cv2.waitKey(0)
|
||||
Reference in New Issue
Block a user