Skip to content
Snippets Groups Projects
Commit 2434ef13 authored by lhuxohl's avatar lhuxohl
Browse files

created framework for excersice 02_01

parent 8679b8c0
No related branches found
No related tags found
No related merge requests found
*.ipynb_checkpoints
bildverarbeitung/
\ No newline at end of file
%% Cell type:markdown id: tags:
# Aufgabe
Schreiben Sie eine Funktion, die eine beliebige Skalierung von Bildern durchführt. Implementieren Sie hierzu das Verfahren aus der Vorlesung und verwenden Sie nicht die Skalierfunktion aus OpenCV.
%% Cell type:code id: tags:
``` python
%matplotlib inline
from matplotlib import pyplot as plt
import cv2 as cv
import numpy as np
import os
def scale(img, height, width):
# Hinweis: Der Typ der Bilder wird hier geändert um Overflows zu vermeiden (siehe Beispiele)
img = img.astype(np.float)
result = np.zeros((height,width,3), np.float)
# TODO: skalieren Sie das Bild und speichern Sie das Ergebnis in result
return result.astype(np.uint8)
img_directory = '../resources'
file_uniansicht = os.path.join(img_directory, 'Uniansicht.jpg')
file_windrad = os.path.join(img_directory, 'Windrad.jpg')
img_uniansicht = cv.imread(file_uniansicht)
img_windrad = cv.imread(file_windrad)
fig, axs = plt.subplots(2, 2, figsize = (9, 9))
fig.tight_layout(h_pad=4)
axs[0, 0].imshow(cv.cvtColor(scale(img_uniansicht, 454, 454), cv.COLOR_BGR2RGB))
axs[0, 1].imshow(cv.cvtColor(scale(img_windrad, 437, 437), cv.COLOR_BGR2RGB))
axs[1, 0].imshow(cv.cvtColor(scale(img_uniansicht, 1200, 900), cv.COLOR_BGR2RGB))
axs[1, 1].imshow(cv.cvtColor(scale(img_windrad, 300, 200), cv.COLOR_BGR2RGB))
_ = axs[1, 1].set_title('')
```
%% Output
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment