Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the resize documentation. #30

Merged
merged 1 commit into from
Jun 12, 2023
Merged

Conversation

zivy
Copy link
Member

@zivy zivy commented Jun 9, 2023

The runtime difference between resizing with anti-aliasing and without is significant. This may be an issue when the function is used in a context involving user interaction.

@zivy
Copy link
Member Author

zivy commented Jun 9, 2023

Code illustrating the runtime behavior:

import SimpleITK as sitk
from SimpleITK.utilities.resize import resize
import time
import numpy as np

image = sitk.ReadImage("puppy.jpg")

time_diff = []
for i in range(5):
  t0 = time.time()
  resize(image, [64,64], fill_value=0, anti_aliasing_sigma=0)
  t1 = time.time()
  time_diff.append(t1-t0)

print(f"Time without antialiasing {np.mean(time_diff)}")

time_diff = []
for i in range(5):
  t0 = time.time()
  resize(image, [64,64], fill_value=0, anti_aliasing_sigma=None)
  t1 = time.time()
  time_diff.append(t1-t0)

print(f"Time with default antialiasing {np.mean(time_diff)}")

Output was:

Time without antialiasing 0.005415868759155273
Time with default antialiasing 0.03511381149291992

@zivy zivy requested a review from blowekamp June 9, 2023 13:52
@@ -28,6 +28,9 @@ def resize(
isotropic. The physical extent of the image's data is retained in the new image, with the new image's spacing
adjusted to achieve the desired size. The image is centered in the new image.

By default the function will perform anti-aliasing. If runtime is of concern (e.g. resizing multiple images
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to:

Anti-aliasing is enabled by default.

Performance can be increased by disabling anti-aliasing ( anti_aliasing_sigma=0 ), and by setting the interpolator to sitkNearestNeighbor at the cost of decreasing quality.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

The runtime difference between resizing with anti-aliasing and without
is significant. This may be an issue when the function is used in a
context involving user interaction.
Copy link
Member

@blowekamp blowekamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@zivy zivy merged commit acb19db into SimpleITK:main Jun 12, 2023
@zivy zivy deleted the updateDocumentation branch June 12, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants