Skip to content

Commit

Permalink
Merge branch 'kallewesterling/issue166' into analyse_preds
Browse files Browse the repository at this point in the history
  • Loading branch information
rwood-97 committed Dec 12, 2023
2 parents 7369464 + 462983d commit 9ee0cdf
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mapreader/annotate/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

warnings.filterwarnings("ignore", category=UserWarning)

MAX_SIZE = 100
MAX_SIZE = 1000

_CENTER_LAYOUT = widgets.Layout(
display="flex", flex_flow="column", align_items="center"
Expand Down Expand Up @@ -92,7 +92,7 @@ class Annotator(pd.DataFrame):
- ``buttons_per_row``: Number of buttons to display per row. Default: None.
- ``ascending``: Whether to sort the DataFrame in ascending order. Default: True.
- ``surrounding``: The number of surrounding images to show for context. Default: 1.
- ``max_size``: The size in pixels for the longest side to which constrain each patch image. Default: 100.
- ``max_size``: The size in pixels for the longest side to which constrain each patch image. Default: 1000.
- ``resize_to``: The size in pixels for the longest side to which resize each patch image. Default: None.
"""

Expand Down Expand Up @@ -516,10 +516,6 @@ def get_context(self):
def get_path(image_path, dim=True):
# Resize the image
im = Image.open(image_path)
if max(im.size) > self.max_size:
print(f"[DEBUG] Resizing {image_path} to {self.max_size}")
im = ImageOps.contain(im, (self.max_size, self.max_size))
print(f"[DEBUG] --> {im.size}")

# Dim the image
if dim is True or dim == "True":
Expand Down Expand Up @@ -597,6 +593,12 @@ def get_empty_square():
context_image = ImageOps.contain(
context_image, (self.resize_to, self.resize_to)
)
# only constrain to max size if not resize_to
elif max(context_image.size) > self.max_size:
context_image = ImageOps.contain(
context_image, (self.max_size, self.max_size)
)

return context_image

def annotate(
Expand Down Expand Up @@ -818,6 +820,9 @@ def get_patch_image(self, ix: int) -> Image:

if self.resize_to is not None:
image = ImageOps.contain(image, (self.resize_to, self.resize_to))
# only constrain to max size if not resize_to
elif max(image.size) > self.max_size:
image = ImageOps.contain(image, (self.max_size, self.max_size))

return image

Expand Down

0 comments on commit 9ee0cdf

Please sign in to comment.