Skip to content

Commit

Permalink
fix pad
Browse files Browse the repository at this point in the history
  • Loading branch information
karaposu committed Jul 6, 2024
1 parent 3548453 commit 94565f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='visual_debugger', # Package name
version='0.2.91', # Version of your package
version='0.2.92', # Version of your package
author='Enes Kuzucu', # Your name

description='A module to help debugging visual workflows', # Short description
Expand Down
14 changes: 9 additions & 5 deletions visual_debugger/visual_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,16 @@ def pad_images_to_match_height(self, img1, img2):
"""Pads two images to match their heights without scaling."""
height1, width1 = img1.shape[:2]
height2, width2 = img2.shape[:2]

if height1 > height2:
padding = (height1 - height2) // 2
img2 = cv2.copyMakeBorder(img2, padding, padding, 0, 0, cv2.BORDER_CONSTANT, value=[0, 0, 0])
padding_top = (height1 - height2) // 2
padding_bottom = height1 - height2 - padding_top
img2 = cv2.copyMakeBorder(img2, padding_top, padding_bottom, 0, 0, cv2.BORDER_CONSTANT, value=[0, 0, 0])
elif height2 > height1:
padding = (height2 - height1) // 2
img1 = cv2.copyMakeBorder(img1, padding, padding, 0, 0, cv2.BORDER_CONSTANT, value=[0, 0, 0])
padding_top = (height2 - height1) // 2
padding_bottom = height2 - height1 - padding_top
img1 = cv2.copyMakeBorder(img1, padding_top, padding_bottom, 0, 0, cv2.BORDER_CONSTANT, value=[0, 0, 0])

return img1, img2

def main():
Expand Down Expand Up @@ -344,5 +348,5 @@ def main():
# Merge and save all debug images
vd.cook_merged_img()

if __name__ == '__main__':
if __name__ == '__nun__':
main()

0 comments on commit 94565f9

Please sign in to comment.