Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Ergänzende Notebooks für Digitalisierung in Verkehr und Logistik
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
W-12
öffentlich
Ergänzende Notebooks für Digitalisierung in Verkehr und Logistik
Commits
a2b30424
Commit
a2b30424
authored
3 years ago
by
Marvin Kastner
Browse files
Options
Downloads
Patches
Plain Diff
apply coding conventions, re-run notebooks (still work)
parent
18e8086e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bilderkennung/03 Repraesentation von Farbbildern.ipynb
+9
-9
9 additions, 9 deletions
bilderkennung/03 Repraesentation von Farbbildern.ipynb
bilderkennung/04 Visualisierung des Farbverlaufs aus der Vorlesung.ipynb
+18
-5
18 additions, 5 deletions
...4 Visualisierung des Farbverlaufs aus der Vorlesung.ipynb
with
27 additions
and
14 deletions
bilderkennung/03 Repraesentation von Farbbildern.ipynb
+
9
−
9
View file @
a2b30424
...
@@ -141,11 +141,11 @@
...
@@ -141,11 +141,11 @@
},
},
"outputs": [],
"outputs": [],
"source": [
"source": [
"plt.imshow(color_image[:,:,0], cmap=\"gray\")\n",
"plt.imshow(color_image[:,
:,
0], cmap=\"gray\")\n",
"plt.show()\n",
"plt.show()\n",
"plt.imshow(color_image[:,:,1], cmap=\"gray\")\n",
"plt.imshow(color_image[:,
:,
1], cmap=\"gray\")\n",
"plt.show()\n",
"plt.show()\n",
"plt.imshow(color_image[:,:,2], cmap=\"gray\")\n",
"plt.imshow(color_image[:,
:,
2], cmap=\"gray\")\n",
"plt.show()"
"plt.show()"
]
]
},
},
...
@@ -176,9 +176,9 @@
...
@@ -176,9 +176,9 @@
},
},
"outputs": [],
"outputs": [],
"source": [
"source": [
"plt.hist(color_image[:,:,0].flatten(), bins='auto', color=\"red\", alpha=.4, label=\"rot\")\n",
"plt.hist(color_image[:,
:,
0].flatten(), bins='auto', color=\"red\", alpha=.4, label=\"rot\")\n",
"plt.hist(color_image[:,:,1].flatten(), bins='auto', color=\"green\", alpha=.4, label=\"grün\")\n",
"plt.hist(color_image[:,
:,
1].flatten(), bins='auto', color=\"green\", alpha=.4, label=\"grün\")\n",
"plt.hist(color_image[:,:,2].flatten(), bins='auto', color=\"darkblue\", alpha=.4, label=\"blau\")\n",
"plt.hist(color_image[:,
:,
2].flatten(), bins='auto', color=\"darkblue\", alpha=.4, label=\"blau\")\n",
"plt.title(\"Histogramm Rot-Grün-Blau\")\n",
"plt.title(\"Histogramm Rot-Grün-Blau\")\n",
"plt.legend()\n",
"plt.legend()\n",
"plt.xlabel(\"Intensität des Pixels\")\n",
"plt.xlabel(\"Intensität des Pixels\")\n",
...
@@ -382,7 +382,7 @@
...
@@ -382,7 +382,7 @@
],
],
"metadata": {
"metadata": {
"kernelspec": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3
(ipykernel)
",
"language": "python",
"language": "python",
"name": "python3"
"name": "python3"
},
},
...
@@ -396,7 +396,7 @@
...
@@ -396,7 +396,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.
7.3
"
"version": "3.
8.12
"
},
},
"varInspector": {
"varInspector": {
"cols": {
"cols": {
...
@@ -436,5 +436,5 @@
...
@@ -436,5 +436,5 @@
}
}
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor":
2
"nbformat_minor":
4
}
}
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Repräsentation von Farbbildern
# Repräsentation von Farbbildern
Bilder werden häufig in Form von Rastergrafiken gespeichert.
Bilder werden häufig in Form von Rastergrafiken gespeichert.
Dies bedeutet, dass ein Bild mit einer Breite $m$ und einer Höhe $n$ dann $m
\t
imes n$ Pixel groß ist.
Dies bedeutet, dass ein Bild mit einer Breite $m$ und einer Höhe $n$ dann $m
\t
imes n$ Pixel groß ist.
Ein Bild kann somit als eine Matrix von Pixeln dargestellt werden.
Ein Bild kann somit als eine Matrix von Pixeln dargestellt werden.
Soweit entsprechen Farbbildern den Grauwertbildern.
Soweit entsprechen Farbbildern den Grauwertbildern.
Aber wie können Farben enkodiert werden?
Aber wie können Farben enkodiert werden?
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
imageio
import
imageio
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
skimage.transform
import
skimage.transform
import
skimage.color
import
skimage.color
import
pandas
as
pd
import
pandas
as
pd
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Zunächst wird ein Farbbild geladen.
Zunächst wird ein Farbbild geladen.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
color_image
=
imageio
.
imread
(
"
imageio:chelsea.png
"
)
color_image
=
imageio
.
imread
(
"
imageio:chelsea.png
"
)
plt
.
imshow
(
color_image
)
plt
.
imshow
(
color_image
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Das Bild verfügt, ebenso wie ein Grauwertbild, über eine Breite und eine Höhe.
Das Bild verfügt, ebenso wie ein Grauwertbild, über eine Breite und eine Höhe.
Darüber hinaus gibt es noch eine Anzahl von Layers.
Darüber hinaus gibt es noch eine Anzahl von Layers.
Grauwertbilder haben nur einen Layer, die Intensitätswerte.
Grauwertbilder haben nur einen Layer, die Intensitätswerte.
Farbbilder verfügen über mehrere Layer:
Farbbilder verfügen über mehrere Layer:
Für die Farben Rot, Grün und Blau werden jeweils die Intensitätswerte angegeben.
Für die Farben Rot, Grün und Blau werden jeweils die Intensitätswerte angegeben.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
height
,
width
,
dim
=
color_image
.
shape
height
,
width
,
dim
=
color_image
.
shape
height
,
width
,
dim
height
,
width
,
dim
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Hier ist anhand der Variablen
`dim`
zu erkennen, dass es drei Layer gibt.
Hier ist anhand der Variablen
`dim`
zu erkennen, dass es drei Layer gibt.
Im Handbuch von imageio ist nachlesbar, dass der erste Layer Rot, der zweite Grün und der dritte Blau darstellt.
Im Handbuch von imageio ist nachlesbar, dass der erste Layer Rot, der zweite Grün und der dritte Blau darstellt.
Es gibt auch andere Bibliotheken, wie z. B. OpenCV, die eine andere Sortierung der Layer vornehmen.
Es gibt auch andere Bibliotheken, wie z. B. OpenCV, die eine andere Sortierung der Layer vornehmen.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Dieses Bild kann man sich auch als Matrix anzeigen lassen, indem man sich den Wert der Variablen
`color_image`
direkt anzeigen lässt.
Dieses Bild kann man sich auch als Matrix anzeigen lassen, indem man sich den Wert der Variablen
`color_image`
direkt anzeigen lässt.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
color_image
color_image
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Man kann auf die einzelnen Farben mithilfe der Befehle
`color_image[:,:,0]`
,
`color_image[:,:,1]`
und
`color_image[:,:,2]`
direkt zugreifen.
Man kann auf die einzelnen Farben mithilfe der Befehle
`color_image[:,:,0]`
,
`color_image[:,:,1]`
und
`color_image[:,:,2]`
direkt zugreifen.
Dies entspricht den Intensitätswerten der Farben Rot, Grün und Blau.
Dies entspricht den Intensitätswerten der Farben Rot, Grün und Blau.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
imshow
(
color_image
[:,:,
0
],
cmap
=
"
gray
"
)
plt
.
imshow
(
color_image
[:,
:,
0
],
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
plt
.
imshow
(
color_image
[:,:,
1
],
cmap
=
"
gray
"
)
plt
.
imshow
(
color_image
[:,
:,
1
],
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
plt
.
imshow
(
color_image
[:,:,
2
],
cmap
=
"
gray
"
)
plt
.
imshow
(
color_image
[:,
:,
2
],
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Das oberste Bild, das den Rotanteil repräsentiert ist sehr hell, sprich die Intensität ist hoch.
Das oberste Bild, das den Rotanteil repräsentiert ist sehr hell, sprich die Intensität ist hoch.
Das unterste Bild, das den Blauanteil repräsentiert, ist eher dunkel, sprich die Intenität ist niedrig.
Das unterste Bild, das den Blauanteil repräsentiert, ist eher dunkel, sprich die Intenität ist niedrig.
Dadurch können wir darauf schließen, dass die Katze eher rötlich als bläulich aussieht.
Dadurch können wir darauf schließen, dass die Katze eher rötlich als bläulich aussieht.
Eine andere Möglichkeit, dies zu visualisieren, sind Histogramme.
Eine andere Möglichkeit, dies zu visualisieren, sind Histogramme.
Dafür werden mithilfe der Methode
`flatten`
alle Pixel nacheinander gesetzt und sind somit eine 1-dimensionale Liste.
Dafür werden mithilfe der Methode
`flatten`
alle Pixel nacheinander gesetzt und sind somit eine 1-dimensionale Liste.
Dann werden die Häufigkeiten der Zahlenwerte analysiert.
Dann werden die Häufigkeiten der Zahlenwerte analysiert.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
hist
(
color_image
[:,:,
0
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
red
"
,
alpha
=
.
4
,
label
=
"
rot
"
)
plt
.
hist
(
color_image
[:,
:,
0
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
red
"
,
alpha
=
.
4
,
label
=
"
rot
"
)
plt
.
hist
(
color_image
[:,:,
1
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
green
"
,
alpha
=
.
4
,
label
=
"
grün
"
)
plt
.
hist
(
color_image
[:,
:,
1
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
green
"
,
alpha
=
.
4
,
label
=
"
grün
"
)
plt
.
hist
(
color_image
[:,:,
2
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
darkblue
"
,
alpha
=
.
4
,
label
=
"
blau
"
)
plt
.
hist
(
color_image
[:,
:,
2
].
flatten
(),
bins
=
'
auto
'
,
color
=
"
darkblue
"
,
alpha
=
.
4
,
label
=
"
blau
"
)
plt
.
title
(
"
Histogramm Rot-Grün-Blau
"
)
plt
.
title
(
"
Histogramm Rot-Grün-Blau
"
)
plt
.
legend
()
plt
.
legend
()
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
xlim
([
0
,
255
])
plt
.
xlim
([
0
,
255
])
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Die automatisch gewählte Bin-Größe ist vielleicht etwas klein.
Die automatisch gewählte Bin-Größe ist vielleicht etwas klein.
Wir können hier weiter "herauszoomen".
Wir können hier weiter "herauszoomen".
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
hist
(
color_image
[:,:,
0
].
flatten
(),
bins
=
30
,
color
=
"
red
"
,
alpha
=
.
4
,
label
=
"
rot
"
)
plt
.
hist
(
color_image
[:,:,
0
].
flatten
(),
bins
=
30
,
color
=
"
red
"
,
alpha
=
.
4
,
label
=
"
rot
"
)
plt
.
hist
(
color_image
[:,:,
1
].
flatten
(),
bins
=
30
,
color
=
"
green
"
,
alpha
=
.
4
,
label
=
"
grün
"
)
plt
.
hist
(
color_image
[:,:,
1
].
flatten
(),
bins
=
30
,
color
=
"
green
"
,
alpha
=
.
4
,
label
=
"
grün
"
)
plt
.
hist
(
color_image
[:,:,
2
].
flatten
(),
bins
=
30
,
color
=
"
darkblue
"
,
alpha
=
.
4
,
label
=
"
blau
"
)
plt
.
hist
(
color_image
[:,:,
2
].
flatten
(),
bins
=
30
,
color
=
"
darkblue
"
,
alpha
=
.
4
,
label
=
"
blau
"
)
plt
.
title
(
"
Histogramm Rot-Grün-Blau
"
)
plt
.
title
(
"
Histogramm Rot-Grün-Blau
"
)
plt
.
legend
()
plt
.
legend
()
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
xlim
([
0
,
255
])
plt
.
xlim
([
0
,
255
])
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Nun verwerfen wir die Farbinformationen und arbeiten nur mit den Grauwerten weiter.
Nun verwerfen wir die Farbinformationen und arbeiten nur mit den Grauwerten weiter.
Dafür werden die drei Farben in Grauwerte umgerechnet.
Dafür werden die drei Farben in Grauwerte umgerechnet.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
gray_image
=
skimage
.
color
.
rgb2gray
(
color_image
)
gray_image
=
skimage
.
color
.
rgb2gray
(
color_image
)
plt
.
imshow
(
gray_image
,
cmap
=
"
gray
"
)
plt
.
imshow
(
gray_image
,
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Nun erstellen wir uns hiervon das Histogramm.
Nun erstellen wir uns hiervon das Histogramm.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
n
,
bins
,
patches
=
plt
.
hist
(
gray_image
.
flatten
(),
bins
=
30
,
color
=
"
dimgray
"
,
alpha
=
.
4
,
label
=
"
Intensität
"
)
n
,
bins
,
patches
=
plt
.
hist
(
gray_image
.
flatten
(),
bins
=
30
,
color
=
"
dimgray
"
,
alpha
=
.
4
,
label
=
"
Intensität
"
)
plt
.
title
(
"
Histogramm Grauwertbild
"
)
plt
.
title
(
"
Histogramm Grauwertbild
"
)
plt
.
legend
()
plt
.
legend
()
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
xlabel
(
"
Intensität des Pixels
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
ylabel
(
"
Anzahl an Pixeln
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Der Aufruf der Histogramm-Funktion gibt auch Werte zurück.
Der Aufruf der Histogramm-Funktion gibt auch Werte zurück.
Diese haben wir oben beim Farb-Beispiel einfach verfallen lassen.
Diese haben wir oben beim Farb-Beispiel einfach verfallen lassen.
Die Variablen
`n`
und
`bins`
sagen etwas darüber aus, wie das Histogramm inhaltlich angelegt worden ist.
Die Variablen
`n`
und
`bins`
sagen etwas darüber aus, wie das Histogramm inhaltlich angelegt worden ist.
Die Variable
`patches`
ist dafür da, um die Visualisierung weiter zu beeinflusse, z. B. für wisseschaftliche Publikationen.
Die Variable
`patches`
ist dafür da, um die Visualisierung weiter zu beeinflusse, z. B. für wisseschaftliche Publikationen.
Die Variable
`bins`
beinhaltet die Trennlinien auf der X-Achse.
Die Variable
`bins`
beinhaltet die Trennlinien auf der X-Achse.
Bei jeder Trennlinie hört der letzte Bin auf und der neue Bin fängt an.
Bei jeder Trennlinie hört der letzte Bin auf und der neue Bin fängt an.
Die Variable
`n`
besagt, wie viele Beobachtungen in dem entsprechenden Bin liegen.
Die Variable
`n`
besagt, wie viele Beobachtungen in dem entsprechenden Bin liegen.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
bins
,
n
bins
,
n
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Das Umwandeln von dem Farb- in ein Grauwertbild hatte hier zu Konsequenz, dass auch die interne Repräsentation umgestellt wurde.
Das Umwandeln von dem Farb- in ein Grauwertbild hatte hier zu Konsequenz, dass auch die interne Repräsentation umgestellt wurde.
Dies ist nur ein Implementations-Detail, allerdings muss man beim Programmieren auf diese achten.
Dies ist nur ein Implementations-Detail, allerdings muss man beim Programmieren auf diese achten.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Im nächsten Schritt skalieren wir das Bild auf sehr wenige Pixel herunter.
Im nächsten Schritt skalieren wir das Bild auf sehr wenige Pixel herunter.
Dadurch werden die Matrizen kleiner und besser verständlich.
Dadurch werden die Matrizen kleiner und besser verständlich.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
small_image
=
skimage
.
transform
.
resize
(
gray_image
,
[
int
(
height
/
32
),
int
(
width
/
32
)],
mode
=
"
constant
"
)
small_image
=
skimage
.
transform
.
resize
(
gray_image
,
[
int
(
height
/
32
),
int
(
width
/
32
)],
mode
=
"
constant
"
)
plt
.
imshow
(
small_image
,
cmap
=
"
gray
"
)
plt
.
imshow
(
small_image
,
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Hier kann man die Katze nur noch erahnen.
Hier kann man die Katze nur noch erahnen.
Dafür werden aber nun alle Werte der Matrix dargestellt.
Dafür werden aber nun alle Werte der Matrix dargestellt.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
small_image
small_image
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Wie kann man nun die Intensitätswerte interpretieren?
Wie kann man nun die Intensitätswerte interpretieren?
Sie liegen zwischen 0 und 1: Eine hohe Intensität wird durch die Farbe Weiß repräsentiert und der Zahlenwert ist nahe 1.
Sie liegen zwischen 0 und 1: Eine hohe Intensität wird durch die Farbe Weiß repräsentiert und der Zahlenwert ist nahe 1.
Niedrige Intensitäten werden durch die Farbe Schwarz repräsentiert und der Zahlenwert ist nahe 0.
Niedrige Intensitäten werden durch die Farbe Schwarz repräsentiert und der Zahlenwert ist nahe 0.
Eine übersichtlichere Darstellung kann man dadurch erhalten, dass man
`pandas`
einsetzt.
Eine übersichtlichere Darstellung kann man dadurch erhalten, dass man
`pandas`
einsetzt.
An dieser Stelle wird das Modul nur dafür eingesetzt, die Matrix schön zu layouten.
An dieser Stelle wird das Modul nur dafür eingesetzt, die Matrix schön zu layouten.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
small_image_as_df
=
pd
.
DataFrame
(
small_image
)
small_image_as_df
=
pd
.
DataFrame
(
small_image
)
small_image_as_df
small_image_as_df
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Eine andere häufige Repräsentation sind Intensitätswerte zwischen 0 (schwarz) und 255 (weiß).
Eine andere häufige Repräsentation sind Intensitätswerte zwischen 0 (schwarz) und 255 (weiß).
Dies kann man einfach durch das Multiplizieren mit einem Skalar erhalten.
Dies kann man einfach durch das Multiplizieren mit einem Skalar erhalten.
Danach muss noch der Typ von
`float`
auf
`int`
geändert werden.
Danach muss noch der Typ von
`float`
auf
`int`
geändert werden.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
small_image_as_int
=
(
small_image
*
255
).
astype
(
int
)
small_image_as_int
=
(
small_image
*
255
).
astype
(
int
)
pd
.
DataFrame
(
small_image_as_int
)
pd
.
DataFrame
(
small_image_as_int
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
imshow
(
small_image_as_int
,
cmap
=
"
gray
"
)
plt
.
imshow
(
small_image_as_int
,
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Wie man sieht, ist die Darstellung als Bild gleich.
Wie man sieht, ist die Darstellung als Bild gleich.
Ob man Werte zwischen 0 und 1 (float) oder zwischen 0 und 255 (int) verwendet, ist nur eine Frage der internen Darstellung.
Ob man Werte zwischen 0 und 1 (float) oder zwischen 0 und 255 (int) verwendet, ist nur eine Frage der internen Darstellung.
Darüber hinaus gibt es noch viele andere Möglichkeiten, Intensitätswerte als Zahlen zu repräsentieren.
Darüber hinaus gibt es noch viele andere Möglichkeiten, Intensitätswerte als Zahlen zu repräsentieren.
...
...
This diff is collapsed.
Click to expand it.
bilderkennung/04 Visualisierung des Farbverlaufs aus der Vorlesung.ipynb
+
18
−
5
View file @
a2b30424
...
@@ -17,8 +17,14 @@
...
@@ -17,8 +17,14 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"df = pd.DataFrame(np.matrix(\"0 0 1 1 2 2 2 4; 1 1 2 1 2 3 4 4; 1 2 2 2 3 4 4 6; \"\n",
"df = pd.DataFrame(\n",
" + \"2 3 3 4 4 4 5 6; 2 4 4 4 5 5 6 7; 3 4 5 6 7 7 8 8; 4 5 7 5 4 5 9 9; 6 6 7 4 3 6 9 10\"))\n",
" np.matrix(\n",
" \"0 0 1 1 2 2 2 4; 1 1 2 1 2 3 4 4; 1 2 2 2 3 4 4 6; \"\n",
" \"2 3 3 4 4 4 5 6; 2 4 4 4 5 5 6 7; 3 4 5 6 7 7 8 8; \"\n",
" \"4 5 7 5 4 5 9 9; 6 6 7 4 3 6 9 10\"\n",
" )\n",
")\n",
"\n",
"df"
"df"
]
]
},
},
...
@@ -31,11 +37,18 @@
...
@@ -31,11 +37,18 @@
"plt.imshow(df.values, cmap=\"gray\")\n",
"plt.imshow(df.values, cmap=\"gray\")\n",
"plt.show()"
"plt.show()"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
}
],
],
"metadata": {
"metadata": {
"kernelspec": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3
(ipykernel)
",
"language": "python",
"language": "python",
"name": "python3"
"name": "python3"
},
},
...
@@ -49,9 +62,9 @@
...
@@ -49,9 +62,9 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.
7.3
"
"version": "3.
8.12
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor":
2
"nbformat_minor":
4
}
}
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
df
=
pd
.
DataFrame
(
np
.
matrix
(
"
0 0 1 1 2 2 2 4; 1 1 2 1 2 3 4 4; 1 2 2 2 3 4 4 6;
"
df
=
pd
.
DataFrame
(
+
"
2 3 3 4 4 4 5 6; 2 4 4 4 5 5 6 7; 3 4 5 6 7 7 8 8; 4 5 7 5 4 5 9 9; 6 6 7 4 3 6 9 10
"
))
np
.
matrix
(
"
0 0 1 1 2 2 2 4; 1 1 2 1 2 3 4 4; 1 2 2 2 3 4 4 6;
"
"
2 3 3 4 4 4 5 6; 2 4 4 4 5 5 6 7; 3 4 5 6 7 7 8 8;
"
"
4 5 7 5 4 5 9 9; 6 6 7 4 3 6 9 10
"
)
)
df
df
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
imshow
(
df
.
values
,
cmap
=
"
gray
"
)
plt
.
imshow
(
df
.
values
,
cmap
=
"
gray
"
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:code id: tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment