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

resizing an image while retaining physical location. #13

Merged
merged 4 commits into from
Jun 7, 2023

Conversation

zivy
Copy link
Member

@zivy zivy commented Mar 29, 2023

resolves #4

@zivy zivy requested a review from blowekamp March 29, 2023 19:12
@blowekamp
Copy link
Member

@zivy This does not appear to be a general "resize" method.

@zivy
Copy link
Member Author

zivy commented Apr 3, 2023

@blowekamp, you are correct.

This resize keeps the original physical aspect ratio and makes the image isotropic. Function name should reflect this, but I think it is a useful function. Would appreciate any ideas you have for a better function name (it's harder to get the name right than the implementation).

@blowekamp
Copy link
Member

@zivy We could have many function for different things, or functions with parameters to control behavior.

From #4 I said:

The method should be further generalized with an option to preserve the aspect ratio and to select the output pixel type.

There should be a argument added "preserve_physical_ratio". The current configuration would be when preserve_physical_ratio is true, otherwise the input image would fill the requests output resolution. This behavior would be similar to scikit-image resize and opencv resize.

We can add parameterization for the interpolator and antialiasing strategy later.

@blowekamp blowekamp force-pushed the resize branch 3 times, most recently from ef9f997 to 8fbbf64 Compare June 2, 2023 14:48
@blowekamp blowekamp changed the title WIP: resizing an image while retaining original aspect ratio. resizing an image while retaining physical location. Jun 5, 2023
@blowekamp blowekamp requested a review from dave3d June 5, 2023 15:42
SimpleITK/utilities/resize.py Outdated Show resolved Hide resolved
interpolator=sitk.sitkLinear,
fill_value: float = 0.0,
use_nearest_extrapolator: bool = False,
anti_aliasing_sigma: Union[None, float, Sequence[float]] = None,
Copy link
Member Author

Choose a reason for hiding this comment

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

I expected the default for anti_aliasing_sigma to be 0, no antialiasing. The value of None results in antialiasing with a default sigma.

Possibly change to 0?

Copy link
Member

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

The resize method is a high level turn key method which automatically configures the itk resample filter to produce a good quality image. Enabling antialiasing by default follows this intention.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it. Makes sense given the intended turnkey aspect of the function.

Copy link
Member

@dave3d dave3d left a comment

Choose a reason for hiding this comment

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

Could use a test with a 3d image.

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.

All comments have been resolved.

@blowekamp blowekamp merged commit 3359c5a into SimpleITK:main Jun 7, 2023
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.

Resize and scale intensity of image while maintaining aspect ratio
3 participants