question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 3 years ago
  • Comments:20 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
anibalicommented, Oct 7, 2021

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.

2reactions
shijianjiancommented, Mar 11, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found