-
Notifications
You must be signed in to change notification settings - Fork 258
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
reset_camera does not correctly compute the distance #1079
Comments
Thanks both!! This is absolutely fantastic... I could not debug myself that one :) from vedo import *
# settings.use_parallel_projection = True
img = Image(dataurl + 'dog.jpg')#.scale(0.01)
print(f'Image dimensions: {img.dimensions()}')
show(img, zoom="tightest", size=img.dimensions()-1)
thanks for this too, I will definitely look at what can be done to address that. |
Hi, Marco,
I was puzzled why plotting an image (Image) produces a visible padding space around even at zoom="tightest" which is supposed to be giving a negligible 0.0001 size margin. Even if
Plotter
is instantiated with the exact image size. Take an example:There is a visible padding even on the top and the bottom of the image and (289.71, 360.639) is not the centre of the 581 by 723 image because of the padding.
Since plotting with
zoom="tightest"
callsreset_camera
method fromplotter.py
, let's go along its lines:Thus x1 and y1 are the last pixel coordinates, but the image size is not x1-x0 by y1-y0: it should be x1-x0+1 by y1-y0+1 below:
I do not know the rational behind 0.999 though. In the next line:
np.sin
should definitely benp.tan
. The difference is not so small: 1393.4 vs. 1345.9There are also the following problems.
Plot a 2D-image:
so the bounds are in reversed order, making
dx, dy = x1 - x0, y1 - y0 and distance negative:
Thus the camera after reset has jumped to the opposite side of the XY-plane.
The following is a suggested fix:
After this, no padding produced around the image
the focal point is in the centre of the image: (290.5, 361.5) and the distance is (almost) as expected!
A general comment: calling argument
zoom
inPlotter.show
is misleading: when you zoom a camera lens you do not change the position, but the view angle. This is also whatZoom
function in vtk does as I can see.But
zoom
when passed toreset_camera
above moves the camera position instead, leaving the angle the same. I would suggest usingpadding
parameter or just the verytight
parameter ofreset_camera
inshow
which could also accept a float "expressed in percent of the average size". Parameterzoom
should change the view angle andpadding
could then preserve the angle and change the distance.Thank you, Marco, for your great work!
Sergei + Eric
The text was updated successfully, but these errors were encountered: