Skip to content

Commit

Permalink
Expand function
Browse files Browse the repository at this point in the history
  • Loading branch information
JargeZ committed Aug 13, 2021
1 parent 62300c6 commit 56db9a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 56db9a8

Please sign in to comment.