Skip to content

Commit

Permalink
Call crop method only if it is needed
Browse files Browse the repository at this point in the history
Regarding issue jrkerns#446

Call crop method only when pixel_difference > 0.
  • Loading branch information
LuisOlivaresJ committed May 30, 2023
1 parent 5894520 commit da77fc6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pylinac/core/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def equate_images(image1: ImageLike, image2: ImageLike) -> tuple[ImageLike, Imag
else:
img = image1
pixel_height_diff = abs(int(round(-physical_height_diff * img.dpmm / 2)))
img.crop(pixel_height_diff, edges=("top", "bottom"))
if pixel_height_diff > 0:
img.crop(pixel_height_diff, edges=("top", "bottom"))

# ...crop width
physical_width_diff = image1.physical_shape[1] - image2.physical_shape[1]
Expand All @@ -99,7 +100,8 @@ def equate_images(image1: ImageLike, image2: ImageLike) -> tuple[ImageLike, Imag
else:
img = image2
pixel_width_diff = abs(int(round(physical_width_diff * img.dpmm / 2)))
img.crop(pixel_width_diff, edges=("left", "right"))
if pixel_width_diff > 0:
img.crop(pixel_width_diff, edges=("left", "right"))

# resize images to be of the same shape
zoom_factor = image1.shape[1] / image2.shape[1]
Expand Down

0 comments on commit da77fc6

Please sign in to comment.