[Bug] warp_perspective does not return the input if used with identity matrix
See original GitHub issue🐛 Bug
The output of kornia.geometry.warp_perspective
does not equal the input if the identity matrix is used.
To Reproduce
Steps to reproduce the behavior:
import torch
from kornia.geometry import warp_perspective
torch.manual_seed(0)
dsize = (32, 16)
src = torch.rand(1, 3, *dsize)
M = torch.eye(3).unsqueeze(0)
dst = warp_perspective(src, M, dsize)
mae = torch.mean(torch.abs(dst - src))
print(mae.item())
0.14952071011066437
Expected behavior
0.0
Environment
kornia==0.4.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (12 by maintainers)
Top Results From Across the Web
OpenCV warpperspective - Stack Overflow
The problem occurs because the homography maps part of the image to negative x,y values which are outside the image area so cannot...
Read more >warpPerspective() to a different origin [SOLVED] edit
I need to apply a perspective transformation to a pixel that is not the origin of the warped image. The warpPerspective() method is...
Read more >kornia.geometry.transform - Read the Docs
The transform is applied to each pixel coordinate in the output image to obtain a point in the input image for interpolation of...
Read more >Apply geometric transformation to image - MATLAB imwarp
If the input transformation tform does not define a forward transform, then use the OutputView name-value argument to accelerate the transformation.
Read more >error: (-215:Assertion failed) _src.total() > 0 in function 'cv
warpPerspective (img,matrix,(width,height)) cv2.imshow("Image", ... You won't get an error from trying to open an image that doesn't exist; it will return ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with the deprecation. It is further supported by the fact that no other library seems to have
align_corners
or equivalent for image-transform-by-matrix functions:In my opinion the addition of an
align_corners
option is confusing, of limited practical use, and increases the likelihood of doing bad things like transforming images and point annotations in subtly different ways despite using the same transformation matrix.I agree with @pmeier that we might add it in the docs to let the users more aware of the differences of the parameter choice. This pic is a nice demonstration.