Initial commit with project files
This commit is contained in:
45
4_Farbrepräsentationen/ü5/README.md
Normal file
45
4_Farbrepräsentationen/ü5/README.md
Normal 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;+3&space;&&space;+2&space;&&space;+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
|
||||
|
||||

|
||||
|
||||
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.
|
||||
BIN
4_Farbrepräsentationen/ü5/data/1.png
Normal file
BIN
4_Farbrepräsentationen/ü5/data/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
34
4_Farbrepräsentationen/ü5/l_a.py
Normal file
34
4_Farbrepräsentationen/ü5/l_a.py
Normal 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)
|
||||
29
4_Farbrepräsentationen/ü5/l_b.py
Normal file
29
4_Farbrepräsentationen/ü5/l_b.py
Normal 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)
|
||||
33
4_Farbrepräsentationen/ü5/l_c.py
Normal file
33
4_Farbrepräsentationen/ü5/l_c.py
Normal 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)
|
||||
29
4_Farbrepräsentationen/ü5/l_d.py
Normal file
29
4_Farbrepräsentationen/ü5/l_d.py
Normal 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)
|
||||
Reference in New Issue
Block a user