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