• Keine Ergebnisse gefunden

Bildverarbeitung Praktikum ¨Ubung 0

N/A
N/A
Protected

Academic year: 2021

Aktie "Bildverarbeitung Praktikum ¨Ubung 0"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Bildverarbeitung Praktikum

Ubung 0¨

Dr. Christina Gillmann April 7, 2020

1 Installieren von Python

Python ist eine interpretierte, h¨ohere Programmiersprache. Der Charme dieser Program- miersprache liegt in einem sehr kurzen und gut lesbarem Programmierstil. Auch wenn Python dadurch schlecht wartbar bei großen Projekten ist, ist es eine sehr gute Basis f¨ur das Bildverarbeitungspraktikum, da ihnen viel Overhead erspart bleibt. Python hat eine starke Community, weshalb sie i.d.R. zu jedem Problem eine L¨osung online finden werden.

Installieren sie Python auf ihrem Rechner. Welche Entwicklungsumgebung sie be- nutzen ist im Prinzip freigestellt. Empfohlen ist https://www.spyder-ide.org/.

Zus¨atzlich zu Python ben¨otigen sie f¨ur dieses Praktikum einige Bibliotheken. Diese k¨onnen sie durch die Anaconda Shell installieren. Sie ben¨otigen vorerst numpy und matplotlib.

Die Befehle dazu sind folgende:

1 conda i n s t a l l −c anaconda numpy

1 conda i n s t a l l −c conda−f o r g e m a t p l o t l i b

Nach dem Installieren der beiden Bibliotheken sollten sie in der Lage sein, folgenden Code in Spyder auszuf¨uhren. Hierzu m¨ussen sie eine neue Datei anlegen und den Code einf¨ugen. Sie ben¨otigen noch ein Bild, welches im gleichen Ornder abgelegt wird wie der Quellcode (eventuell m¨ussen sie den Namen des Bildes in Zeile 5 anpassen).

1 i m p o r t m a t p l o t l i b . p y p l o t a s p l t 2 i m p o r t numpy a s np

3 from PIL i m p o r t Image 4

5 img = Image . open ( ’ t e s t . png ’ ) 6

7 d a t a = np . a s a r r a y ( img , dtype= ’ u i n t 8 ’ ) 8

1

(2)

9 i m g p l o t = p l t . imshow ( d a t a )

2 Erste Schritte in Python

Wenn sie bis jetzt eher C++ oder Java gewohnt sind, kann Python am Anfang etwas befremdlich sein. Betrachten sie folgenden Code und f¨uhren sie ihn aus, indem sie eine neue Quellcode Datei anlegen in welcher der folgende Code enthalten ist.

1 i m p o r t m a t p l o t l i b . p y p l o t a s p l t 2 i m p o r t numpy a s np

3

4 a n i m a g e = p l t . imread ( ’ t e s t . png ’ ) 5 #p l t . imshow ( a n i m a g e )

6

7 r g b w e i g h t s = [ 0 . 2 9 8 9 , 0 . 5 8 7 0 , 0 . 1 1 4 0 ] 8

9 g r a y s c a l e i m a g e = np . d ot ( a n i m a g e [ . . . , : 3 ] , r g b w e i g h t s ) 10 p l t . imshow ( g r a y s c a l e i m a g e , cmap=p l t . get cmap ( ” g r a y ” ) )

a) Was tut dieser Code? Betrachten sie dabei vor allem Zeile 9.

b) Ver¨andern sie die Gewichte in Zeile 7. Wie ¨andert sich das Ergebnis?

2

Referenzen

ÄHNLICHE DOKUMENTE

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the

The Optimal Django Environment Setup How to Lay Out Django Projects Fundamentals of Django App Design Settings and Requirements Files Model Best Practices. Queries and the