[vtkusers] vtkImageViewer2 show zoom factor and visible coordinates
Christian Lackas
lackas at invicro.com
Thu Sep 12 12:15:07 EDT 2013
* Dean Inglis <inglis.dl at gmail.com> [130912 10:05]:
Dear Dean,
thanks for your vtkCoordinate hint, this go me on the right track again.
I now do this to calculate the zoom with which my image is displayed:
float getZoom( vtkRenderer *R, vtkImageData *I ) {
int *dim = I->GetDimensions();
vtkSmartPointer<vtkCoordinate> c = vtkCoordinate::New();
c->SetValue( 0, 0, 0 );
int *res = c->GetComputedDisplayValue( R );
int a = res[0];
c->SetValue(dim[0], 0, 0);
res = c->GetComputedDisplayValue( R );
return static_cast<float>(res[0]-a)/dim[0];
}
This is what you had in mind, right, or am I still doing this overly
complicated?
Adding another image actor for the small preview is also a good idea, will look
into this.
Christian
--
Dr. Christian Lackas, Managing Partner
inviCRO, LLC -- In Imaging Yours
http://www.invicro.com/ http://www.spect-ct.com/
> Hi Christian,
>
> I wrote a class for querying image pixel/voxeld data a while back and I
> could make it available
> to you off-line at your request.
> In the meantime, have a look at http://www.vtk.org/Wiki/VTK/Examples/Cxx in
> particular
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/PickingAPixel2
> and
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/PickingAPixel
>
> For displaying a minimap, I would try adding a second vtkRenderer with a
> smaller viewport
> in your main vtkRenderWindow and place a vtkImageActor within it.
>
> To compute zoom, have a look at vtkCoordinate class, which allows conversion
> between numerous kinds of coordinate types (viewport, normalized viewport,
> world etc.),
> probably make use of the extrema of your viewing window and those of the
> image.
>
> Dean
>
>
>
> On Thu, Sep 12, 2013 at 4:47 AM, Christian Lackas <lackas at invicro.com>wrote:
>
> > Hi Everybody,
> >
> > I display a large 2D image (larger then typical screen resolutions) in a
> > a vtkImageViewer2 and would like to give the user some guidance as to
> > which part she is currently looking at.
> >
> > My questions are:
> > * What is the easiest way to get the zoom (ratio of image to world pixels)?
> > * How can I get the coordinates (in image pixels) of the par of the
> > image that is currently visible?
> >
> > Details:
> >
> > In a first steps, I would like to show the zoom level (100% = one pixel
> > on screen contains exactly one pixel of the image). I looked at
> > vtkCamera and found the Zoom(double) function, pointing me to
> > ParallelScale() (ParallelProjection: On), and this variable seems to be
> > indeed related to the zoom (larger values indicate lower zoom), however,
> > I was not able to derive an absolute number from this (e.g. 50%, so two
> > image pixels are shown in 1 pixel on screen). In my example 100% is
> > around ParallelScale=140.
> > Also vtkCamera::Get(Model)ViewTransformObject()->GetScale() does not
> > work (always returns 1,1,1).
> > I tried to use vtkCamera's Print(stream) method, however, could not find
> > any other values that change with the zoom, and I could not figure out
> > how to use GetProjectionTransformObject(double,double,double) properly.
> >
> > In a next step, I would like to show a small minimap in one corner, just
> > consisting of two rectangles showing the full image and the current view
> > port. For this I would need to know which coordinates (in image pixels)
> > are currently shown.
> > Unfortunately, ImageActors DisplayExtent just contains the full
> > dimensions, and I have not found any other value that seems to be useful
> > (also not in vtkCamera).
> >
> > Any help on this is highly appreciated.
> >
> > Thanks,
> > Christian
> >
> > --
> > Dr. Christian Lackas, Managing Partner
> > inviCRO, LLC -- In Imaging Yours
> > http://www.invicro.com/ http://www.spect-ct.com/
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list