From 56db9a897171e04ccf527ff1aa1d56ad06b89ca0 Mon Sep 17 00:00:00 2001 From: JargeZ Date: Fri, 13 Aug 2021 20:53:21 +0300 Subject: [PATCH] Expand function --- app/funcs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/funcs.py b/app/funcs.py index cc7bfe7..a85ce86 100755 --- a/app/funcs.py +++ b/app/funcs.py @@ -37,3 +37,17 @@ def trim_to_4width(img: numpy.ndarray) -> numpy.ndarray: height, width, channels = img.shape logger.debug(f"┗FIX to wh: {width}x{height} w%4={width % 4}") return img + + +def expand_to_4width(img: numpy.ndarray) -> numpy.ndarray: + """ + Workaround crash if image not divided by 4 + """ + height, width, channels = img.shape + logger.debug(f"┃ Image wh: {width}x{height} w%4={width % 4}") + d = width % 4 + if d != 0: + img = numpy.concatenate((img, img[:, -1:(d + 1) * -1:-1]), axis=1) + height, width, channels = img.shape + logger.debug(f"┗FIX to wh: {width}x{height} w%4={width % 4}") + return img