[vtkusers] Rotating image data

Lic. José M. Rodriguez Bacallao jmrbcu at gmail.com
Fri Jul 9 12:28:10 EDT 2010


does all operation performed by vtkImageReslice are costly?
I don't remember where, but in some book I did read that I should
never modify the pixel matrix (some vtk book), just the camera but as
I see, you did modify the camera, is this ok, why?

On Fri, Jul 9, 2010 at 10:31 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> I'd better add an errata to what I wrote:
>
> 3) Each (x,y,z) point is transformed by the ResliceAxes matrix, and
> then the ResliceTransform, in that order.
>
> I had the two operations reversed.
>
>   David
>
>
> On Fri, Jul 9, 2010 at 8:21 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>> Really, vtkImageReslice is the only straightforward way to rotate an
>> image in VTK.  It does change the pixel matrix, the basic job of
>> ImageReslice is to resample an image through a transform.
>>
>> The operation of vtkImageReslice is like so:
>> 1) The output Extent/Origin/Spacing of vtkImageReslice define an
>> output voxel grid.
>> 2) Reslice loops through all output voxels, and computes the (x,y,z)
>> data coords for each voxel in turn.
>> 3) Each (x,y,z) point is transformed by the ResliceTransform, and then
>> the ResliceAxes matrix, in that order.
>> 4) The reslice's input data is interpolated at the transformed (x',y',z') point.
>> 5) The interpolated value from the input at coordinate (x',y',z') is
>> used to set the value of the output voxel at (x,y,z).
>>
>> Lots of people have trouble with (1).  Because vtkImageReslice isn't a
>> vtkProp it doesn't know anything about how it's output will be
>> displayed, it doesn't know how to properly set its own output voxel
>> grid.  So you should usually set the output Spacing/Origin/Extent
>> manually.  If you don't, then vtkImageReslice will try to "guess" what
>> a reasonable output grid would be, and it will usually guess wrong,
>> because it doesn't know anything about how the image will eventually
>> be displayed.
>>
>> I've had a plan for a long time now to write a vtkProp3D based around
>> vtkImageReslice that will do all the mathematical trickery needed to
>> make VTK more friendly for 3D image display.  In my own image display
>> applications, I set up some low-level observers that keep track of the
>> camera position and the window size, and then have those observers set
>> the vtkImageReslice parameters so that the image displays exactly the
>> way that it should.
>>
>>   David
>>
>>
>>
>>
>> On Fri, Jul 9, 2010 at 7:52 AM, Lic. José M. Rodriguez Bacallao
>> <jmrbcu at gmail.com> wrote:
>>> this may be a silly question:
>>> 1- which is the correct preffered way to rotate(transform) an image,
>>> with the camera or with vtkImageReslice?
>>> 2- does vtkImageReslice change/transform the pixel matrix?
>>>
>>>
>>> On Fri, Jul 9, 2010 at 7:34 AM, Jothy <jothybasu at gmail.com> wrote:
>>>> Some sort of padding befor rotation should help.
>>>>
>>>> Jothy
>>>>
>>>> On Fri, Jul 9, 2010 at 12:32 PM, Srinivasa Rao <srinivas at rsageventures.com>
>>>> wrote:
>>>>>
>>>>> Hi All,
>>>>>    I am trying to rotate vtkImageData using vtkTransform and
>>>>> vtkImageReslice, i used following code to do the job.
>>>>>
>>>>> vtkImageData * rotateImage(vtkImageData *data, QPointF center, int angle)
>>>>> {
>>>>>         vtkTransform *imageTransform = vtkTransform::New();
>>>>>         imageTransform->PostMultiply();
>>>>>         imageTransform->Translate(center.x(), center.y(), 0.0);
>>>>>         imageTransform->RotateZ(angle);
>>>>>        imageTransform->Translate(-center.x(), -center.y(), 0.0);
>>>>>         // Now create filter and set previously created transformation
>>>>>         vtkImageReslice *algo = vtkImageReslice::New();
>>>>>         algo->SetInput(data);
>>>>>         algo->SetInformationInput(data);
>>>>>         algo->SetResliceTransform(imageTransform);
>>>>>         algo->SetInterpolationModeToLinear();
>>>>>         algo->Update();
>>>>>         return algo->GetOutput();
>>>>> }
>>>>>
>>>>> When i try to rotate image data, after rotation the data which is outside
>>>>> the image is getting lost.
>>>>> Is there a way around to rotate image data without data loss..
>>>>> thanks in advance.
>>>>> regards,
>>>>> srinivas.
>>>>> _______________________________________________
>>>>> 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
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Lic. José M. Rodriguez Bacallao
>>> Centro de Biofisica Medica
>>> -----------------------------------------------------------------
>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>>>
>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic
>>> por profesionales
>>> -----------------------------------------------------------------
>>> _______________________________________________
>>> 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
>>>
>>
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-----------------------------------------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-----------------------------------------------------------------



More information about the vtkusers mailing list