Closed sergei9838 closed 3 months ago
Thanks both!! This is absolutely fantastic... I could not debug myself that one :) I think though the +1 should not be there (rather you should subtract 1 from the show(), otherwise it would not work with scaling objects). Just pushed to dev09:
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)
A general comment: calling argument zoom in Plotter.show is misleading: when you zoom a camera lens you do not change the position, but the view angle. This is also what Zoom function in vtk does as I can see.
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. Butzoom
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