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

deform_grid adds random pixels even when the displacement is an array of zeros #17

Open
EmanuelNk opened this issue Jan 30, 2023 · 0 comments

Comments

@EmanuelNk
Copy link

I was using the following code:


X = Image.open('im.jpg')

# resize image
X = X.resize((200, 200))

# convert to grayscale
X = numpy.array(X.convert('L'))

# define a crop region
crop = (slice(50, 150), slice(0, 100))

# generate a deformation grid of 0 
displacement = numpy.zeros((2, 3, 3))
# displacement[0, 1, 1] = 25

# deform full image
X_deformed = elasticdeform.deform_grid(X, displacement)
# compute only the cropped region
X_deformed_crop = elasticdeform.deform_grid(X, displacement, crop=crop)

# the deformation is the same
![output](https://user-images.githubusercontent.com/53420011/215512271-65317d8b-3022-403d-b570-e1c32c7ac899.svg)

numpy.testing.assert_equal(X_deformed[crop], X_deformed_crop)

even while setting the displacement to 0, the result is very noisy and there are random patches in the picture

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

No branches or pull requests

1 participant