[vtkusers] vtkTransform to transform vtkImageData

Jonathan Ruiz Peinado jonathan.ruiz3 at gmail.com
Fri Jun 29 11:20:04 EDT 2012


Thansk Jothybasu, looks fine , I should play with it a bit to see how could
rotate over x,y or z axes, I guess it depends on cos, and sin position in
the matrix.

I'll give a try to vtkTransform anyway to see what's better option.

Thanks.

2012/6/29 Jothybasu Selvaraj <jothybasu at gmail.com>

> Use vtkImageReslice to rotate vtkImageData
>
> This should help you going (though messy)
>
>  //convert angle from degree to radian
>     double angleInRads=vtkMath::RadiansFromDegrees(angle);
>     double cosAngle=cos(angleInRads);
>     double sinAngle =sin(angleInRads);
>     qDebug()<<"cos & sin:"<<cosAngle<<sinAngle;
>
>     static double axialElements[16] = {
>         1, 0, 0, 0,                                         //1,0,0,0
>         0,cosAngle,-sinAngle, 0,            //0,-1,0,0
>         0, sinAngle,cosAngle, 0,            //0,0,-1,0
>         0, 0, 0, 1 };                                     //0,0,0,1
>
>
>    // Set the slice orientation
>      vtkSmartPointer<vtkMatrix4x4> resliceAxes =
>        vtkSmartPointer<vtkMatrix4x4>::New();
>      resliceAxes->DeepCopy(axialElements);
>      // Set the point through which to slice
>      resliceAxes->SetElement(0, 3,0);
>      resliceAxes->SetElement(1, 3,0);
>      resliceAxes->SetElement(2, 3,0);
>
>
>     vtkSmartPointer<vtkImageReslice> res=
>             vtkSmartPointer<vtkImageReslice>::New();
>     res->SetInput( imgData);
>     res->SetInformationInput( imgData);
>     res->SetResliceAxes(resliceAxes);
>     res->SetInterpolationModeToLinear();
>     res->Update();
>     this->rotatedImageData=res->GetOutput();
>
>
> Jothy
>
> On Fri, Jun 29, 2012 at 3:48 PM, David Doria <daviddoria at gmail.com> wrote:
>
>> On Fri, Jun 29, 2012 at 10:45 AM, Jonathan Ruiz Peinado
>> <jonathan.ruiz3 at gmail.com> wrote:
>> > Hi, I need to apply some transformations to a vtkImageData, I though
>> that I
>> > could use vtkTransform or vtkTransformFilter to setup  the
>> trasnformation
>> > put my imageData as input and get the result as the output of
>> > vtkTransformFilter, but it's seems not that easy, there's some example
>> about
>> > it around or something I'm missing.
>> >
>> > Thanks.
>>
>> Can you tell us what isn't working? Compiler errors? Incorrect
>> results? Also please show the code you are using in a very simple
>> example case.
>>
>> David
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Jothybasu Selvaraj
> PhD Student
> University of Liverpool
> UK
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120629/b7914818/attachment.htm>


More information about the vtkusers mailing list