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