Initial commit with project files

This commit is contained in:
2025-06-27 14:34:11 +02:00
commit 7ea3207e63
310 changed files with 9331 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
# Übung 5: Kettencode
Eine Variante für die Abbildung von Konturen is der Kettencode. Im folgenden sollten Bilder in den Kettencode codiert und
Kettencodes in Konturen decodiert werden.
Für die Codierung mit dem Kettencode soll folgende Zuordnung verwendet werden:
<p align="center">
<img src="https://latex.codecogs.com/gif.latex?\begin{bmatrix}&space;3&space;&&space;2&space;&&space;1&space;\\&space;4&space;&&space;&&space;0\\&space;5&space;&&space;6&space;&&space;7&space;\end{bmatrix}" />
</p>
Für die Codierung mit dem differentiellen Kettencode soll folgende Zuordnung verwendet werden:
<p align="center">
<img src="https://latex.codecogs.com/gif.latex?\begin{bmatrix}&space;&plus;3&space;&&space;&plus;2&space;&&space;&plus;1&space;\\&space;4&space;&&space;&&space;0\\&space;-3&space;&&space;-2&space;&&space;-1&space;\end{bmatrix}" />
</p>
## Aufgabe a) Kettencode
Erstellen Sie für das Bild
![](./data/1.png)
einen Kettencode! Beginnen Sie mit dem weißen Pixel oben links und dem Wert 0.
## Aufgabe b) Kettencode
Erstellen Sie das Bild für den Kettencode
```[6 4 6 3 4 5 6 4 2 2 3 2 2 0 0 7 0 2 0 0 7 6]```
## Aufgabe c) Differentieller Kettencode
Erstellen Sie für das Bild aus Aufgabe a)
einen differenziellen Kettencode! Beginnen Sie mit dem Pixel oben links und dem Wert 0.
## Aufgabe d) Differentieller Kettencode
Erstellen Sie das Bild für den differentiellen Kettencode
```[-2 -2 2 -3 1 1 1 -2 -2 0 1 -1 0 -2 0 -1 1 2 -2 0 -1 -1]```
Nutzen Sie als Startrichtung die Richtung 0 nach Definition des Kettencodes.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -0,0 +1,34 @@
import numpy as np
import cv2
line = np.asarray(
[
[0,0, 0,0, 0,0, 0,0],
[1,1, 1,0, 1,1, 1,0],
[1,0, 0,1, 1,0, 0,1],
[1,0, 0,0, 0,0, 1,1],
[0,1, 0,1, 1,1, 1,0],
[0,1, 1,0, 0,1, 0,0],
[0,1, 1,0, 0,0, 0,0],
[0,0, 0,0, 0,0, 0,0],
],
)
# Resize image
line = np.repeat(line, 50, axis=1)
line = np.repeat(line, 50, axis=0)
# Add seperators
line[0::2, ::50] = 1
line[1::2, ::50] = 0
line[::50, 0::2] = 1
line[::50, 1::2] = 0
# Show image
line = line.astype(np.float64)
cv2.imshow("1", line)
cv2.imwrite("./data/1.png", line*255)
cv2.waitKey(0)
chaincode = [0, 0, 7, 0, 2, 0, 0, 7, 6, 4, 6, 4, 6, 3, 4, 5, 6, 4, 2, 2, 3, 2]
print(chaincode)

View File

@@ -0,0 +1,29 @@
import numpy as np
import cv2
line = np.asarray(
[
[0,0, 0,0, 0,0, 0,0],
[1,1, 1,0, 1,1, 1,0],
[1,0, 0,1, 1,0, 0,1],
[1,0, 0,0, 0,0, 1,1],
[0,1, 0,1, 1,1, 1,0],
[0,1, 1,0, 0,1, 0,0],
[0,1, 1,0, 0,0, 0,0],
[0,0, 0,0, 0,0, 0,0],
],
)
# Resize image
line = np.repeat(line, 50, axis=1)
line = np.repeat(line, 50, axis=0)
# Add seperators
line[0::2, ::50] = 1
line[1::2, ::50] = 0
line[::50, 0::2] = 1
line[::50, 1::2] = 0
# Show image
line = line.astype(np.float64)
cv2.imshow("b", line)
cv2.waitKey(0)

View File

@@ -0,0 +1,33 @@
import numpy as np
import cv2
line = np.asarray(
[
[0,0, 0,0, 0,0, 0,0],
[1,1, 1,0, 1,1, 1,0],
[1,0, 0,1, 1,0, 0,1],
[1,0, 0,0, 0,0, 1,1],
[0,1, 0,1, 1,1, 1,0],
[0,1, 1,0, 0,1, 0,0],
[0,1, 1,0, 0,0, 0,0],
[0,0, 0,0, 0,0, 0,0],
],
)
# Resize image
line = np.repeat(line, 50, axis=1)
line = np.repeat(line, 50, axis=0)
# Add seperators
line[0::2, ::50] = 1
line[1::2, ::50] = 0
line[::50, 0::2] = 1
line[::50, 1::2] = 0
# Show image
#line = line.astype(np.float64)
#cv2.imshow("1", line)
#cv2.imwrite("./data/1.png", line*255)
#cv2.waitKey(0)
chaincode = [0, 0, -1, 1, 2, -2, 0, -1, -1, -2, 2, -2, 2, -3, 1, 1, 1, -2, -2, 0, 1, -1]
print(chaincode)

View File

@@ -0,0 +1,29 @@
import numpy as np
import cv2
line = np.asarray(
[
[0,0, 0,0, 0,0, 0,0],
[1,1, 1,0, 1,1, 1,0],
[1,0, 0,1, 1,0, 0,1],
[1,0, 0,0, 0,0, 1,1],
[0,1, 0,1, 1,1, 1,0],
[0,1, 1,0, 0,1, 0,0],
[0,1, 1,0, 0,0, 0,0],
[0,0, 0,0, 0,0, 0,0],
],
)
# Resize image
line = np.repeat(line, 50, axis=1)
line = np.repeat(line, 50, axis=0)
# Add seperators
line[0::2, ::50] = 1
line[1::2, ::50] = 0
line[::50, 0::2] = 1
line[::50, 1::2] = 0
# Show image
line = line.astype(np.float64)
cv2.imshow("d", line)
cv2.waitKey(0)