diff options
author | Leonard Kugis <leonard@kug.is> | 2022-11-27 15:50:13 +0100 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2022-11-27 15:50:13 +0100 |
commit | 3ecf33982354c75dbef45634cb097fec28d69fcd (patch) | |
tree | 4f7557e47eecc0931ddf7e8d15809b9dccfc779f /openCVTools.py | |
parent | b781b4150cf86b78226b616bb68cbad99f133ad2 (diff) |
Übung 1
Diffstat (limited to 'openCVTools.py')
-rw-r--r-- | openCVTools.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/openCVTools.py b/openCVTools.py index 484c3fa..d808dea 100644 --- a/openCVTools.py +++ b/openCVTools.py @@ -25,7 +25,7 @@ def imageStats(img): Returns a few image statistics
'''
s = img.shape
- return f'Width: {s[1]}, Height: {s[0]}, Channels: {s[2]}'
+ return "Width: {}, Height: {}, Channels: {}, Type: {}".format(s[1], s[0], s[2] if len(s) >= 3 else 1, img[0][0][0].dtype if len(s) >= 3 else img[0][0].dtype)
@@ -37,9 +37,12 @@ def showImage(title, originalImg): print(imageStats(originalImg))
img = originalImg.copy()
- img = img[:,:,::-1]
plt.figure(title)
- plt.imshow(img)
+ if len(img.shape) >= 3:
+ img = img[:,:,::-1]
+ plt.imshow(img)
+ else:
+ plt.imshow(img, cmap="gray")
plt.show()
|