From 3ecf33982354c75dbef45634cb097fec28d69fcd Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Sun, 27 Nov 2022 15:50:13 +0100 Subject: =?UTF-8?q?=C3=9Cbung=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openCVTools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'openCVTools.py') 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() -- cgit v1.2.1