-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Can we add anti aliasing to zoom and zoom_to_shape? Zooming to coarse resolution results in interpolation artifcats:
from amid import AMOS
from einops import reduce
dataset = AMOS()
i = dataset.ids[0]
image = dataset.image(i)
spacing = dataset.spacing(i)
print(image.shape, spacing) # (768, 768, 90) [0.5703125 0.5703125 5.]
target_spacing = np.array([5,5,5])
def plot_projections(zi):
front = reduce(zoomed_image, 'w d h -> h w', reduction='max')
side = reduce(zoomed_image, 'w d h -> h d', reduction='max')
top = reduce(zoomed_image, 'w d h -> w d', reduction='max')
fig, axs = plt.subplots(1, 3, figsize=(15,5))
axs[0].imshow(front[::-1], cmap='gray')
axs[1].imshow(side[::-1], cmap='gray')
axs[2].imshow(top, cmap='gray');
from imops import zoom
image_imops = zoom(image, scale_factor=spacing/target_spacing, order=0)
plot_projections(image_imops)This is a known problem, and is typically solved with anti aliasing:
from skimage.transform import rescale
image_skimage = rescale(image, scale=spacing/target_spacing, order=1, anti_aliasing=True)
plot_projections(image_skimage)Metadata
Metadata
Assignees
Labels
No labels

