[vtkusers] vtkImageActor and scaling

endlosschleife1 endlosschleife1 at googlemail.com
Tue Nov 30 09:10:39 EST 2010


>
>> What would be the equivalent if I would use a vtkActor2D?
>>
>
> There is no camera for vtkActor2D, they always use display coordinates
> directly.  Instead of scaling a vtkImageMapper, you have to use
> vtkImageReslice to resample the image at a higher or lower resolution.
>

I was actually looking for accelerated scaling, so this sounds like
vtkActor2D is not be the right thing for that.


>
>
>> The possible reason to do that in my case is that the window level lookup
>> table operation that I need in the vtkImageActor implementation seems to be
>> very slow compared to when I set the window/level of the vtkImageMapper for
>> a vtkActor2D (24ms slower per 512x512 image). I will need to look at that as
>> well, since I assumed that the vtkImageMapper just uses the same lookup
>> table operations, but that's a different story...
>>
>
> What are you using for window/level with vtkImageActor?  The typical way is
> with a vtkLookupTable and vtkImageMapToColors (which can also map to
> greyscale).
>
> The vtkImageActor and the vtkImageMapper work completely differently.  The
> more you expect them to behave similarly to one another, the more you will
> confuse yourself.  Each is designed to utilize a completely different set of
> GPU primitives.
>
>

I'm not sure, but it looks like my implementation probably doesn't use any
GPU acceleration (it seems to be pure image data filtering). It still seemed
to be not as performant as I expected (compared to an implementation where I
only used VTK for the imaging pipeline, but did the LUT application
and visualization separetely).

I create a vtkWindowLevelTable, set the window and center, and then call
build on the lut. Then I used it with a vtkImageMapToColors instance:

vtkImageMapToColors *color = vtkImageMapToColors::New();
color->SetLookupTable(lut); // lut is the vtkWindowLevelTable
color->SetInput(...) // some vtkImageData

Thanks,
Mark



>    David
>
>
>  2010/11/29 David Gobbi <david.gobbi at gmail.com>
>>
>> Hi Mark,
>>>
>>> The camera method you want is SetParallelScale(), it sets the height of
>>> viewport when ParallelProjection is on.
>>>
>>>   David
>>>
>>>   On Mon, Nov 29, 2010 at 8:24 AM, endlosschleife1 <
>>> endlosschleife1 at googlemail.com> wrote:
>>>
>>>>   Hi all,
>>>>
>>>> I'm a bit confused about how cameras are initialized. I would like to
>>>> scale a 2D image (scale a DICOM image to best fit a viewport size). I first
>>>> did this via vtkImageResample and that works fine, but now I would like
>>>> to try this with accelarated scaling and so I wanted to do that as part of
>>>> the visualization pipeline (I hope that means that it is actually using
>>>> OpenGL). I replaced my original vtkActor2D/vtkImageMapper with a
>>>> vtkImageActor. The following works (pseudo code):
>>>>
>>>> Variant 1:
>>>> - add imageActor to renderer, and renderer to renderwindow. Then call
>>>> Render() on renderwindow.
>>>> -> The image displays as expected in the original size.
>>>>
>>>> Variant 2:
>>>> - same as in Variant 1 (including Render() call)
>>>> - renderer->GetActiveCamera()->ParallelProjectionOn()
>>>> - renderer->GetActiveCamera()->Zoom(zoomFactor);
>>>> -> The image displays with the desired scaling.
>>>>
>>>> But variant 2 only works because I called Render() first. I assume this
>>>> somehow initializes the camera of the renderer with exactly the attributes
>>>> that I need, but when I call GetActiveCamera without rendering first this
>>>> (just calling the getter-method) will already) will give a different result
>>>> (in my case a grey box in the upper right corner of the viewport). I'm now
>>>> about to reverse engineer the camera settings after variant 1 was executed
>>>> and set all the camera attributes to the desired initial values (position,
>>>> viewUp, clipping range etc.), but I'm wondering if I'm just missing the more
>>>> appropriate and convenient way to do this (after all the vtkImageActor seems
>>>> to be all about convenience).
>>>>
>>>> Thank you.
>>>>
>>>> Mark
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101130/ee7c9369/attachment.htm>


More information about the vtkusers mailing list