ANTsPy icon indicating copy to clipboard operation
ANTsPy copied to clipboard

Padding ---> Cropping: indices issue?

Open ntustison opened this issue 5 years ago • 1 comments

Describe the bug

Cropping following padding throws an error: Requested region is (at least partially) outside the largest possible region.

To Reproduce

import ants
image = ants.image_read(ants.get_ants_data('r16'))
padded_image = ants.pad_image(image, shape=(300,300))
cropped_image = ants.crop_indices(padded_image, (0, 0), (300, 300))

# This is where the error is thrown.  Perhaps this is expected considering 
# a behind-the-scenes changing of the indices of the image.  The following
# two lines also throw the same error (just for completeness):

cropped_image = ants.crop_indices(padded_image*1, (0, 0), (300, 300))
cropped_image = ants.crop_indices(ants.image_clone(padded_image), (0, 0), (300, 300))

# However, if I do the following:

cropped_image = ants.crop_indices(ants.image_clone(padded_image)*1, (0, 0), (300, 300))

# the operation happens without issue.  I don't know if this is a bug, per se, 
# but it's quirky behavior.  Is this an issue of ANTsPy/ANTsR not keeping
# track of the image indices?

ntustison avatar Jul 24 '20 03:07 ntustison

I think this is a bug - I also expect something related in the recent padding functions that were added - noting different behavior from R - should confirm/address this later.

stnava avatar Jul 30 '20 12:07 stnava