[vtkusers] Reslicer rotation axis

Fabian Torres fabian.trobles at gmail.com
Sun May 29 23:16:43 EDT 2016


Hi David.

Thanks a lot, that solved my problem.

On Fri, May 27, 2016 at 2:46 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> Hi Fabian,
>
> Calling SetResliceAxesOrigin() is the wrong thing to do here.
>
> If you want to rotate around a specific point, you need to build a
> transform matrix that does the following:
> 1) translate by (- P) where P is the desired centre of rotation
> 2) rotate
> 3) translate by P (the same P as above)
>
> Define T as the matrix that translates by -P,
> define R as the pure rotation matrix, and
> define U as the matrix that translates by P:
>
>   M = U R T
>
> The special property of this matrix is that it does not change the
> point that is defined as the centre of rotation:
>
>   M P == P
>
> So you should build matrix M and then call SetResliceAxes(M).
>
>  - David
>
>
> On Fri, May 27, 2016 at 1:26 PM, Fabian Torres <fabian.trobles at gmail.com>
> wrote:
>
>> Hi all.
>>
>> I have a volume and I want to extract the center sagital slice of the
>> volume and rotate it around the x axis in the center of the image. For this
>> I'm using vtkImageReslice and vtkTransform.
>> Everything works fine until I rotate the slice. It is rotating around the
>> origin of the output image (lower left corner of the image) and not through
>> the center of it. Can any one explain to me how do I choose the rotation
>> axis in the transform. here is a brief of my code.
>>
>> const double MainWindow::sagitalElements[16] = {
>> 0, 0, 1, 0,
>> 1, 0, 0, 0,
>> 0, 1, 0, 0,
>> 0, 0, 0, 1
>> };
>>
>> volumeData->GetSpacing(spacing);
>> volumeData->GetOrigin(origin);
>> volumeData->GetDimensions(dimensions);
>>
>> centerSlice[0] = floor(dimensions[0]*0.5);
>> centerSlice[1] = floor(dimensions[1]*0.5);
>> centerSlice[2] = floor(dimensions[2]*0.5);
>>
>> positionCenter[0] = origin[0] + spacing[0] * centerSlice[0];
>> positionCenter[1] = origin[1] + spacing[1] * centerSlice[1];
>> positionCenter[2] = origin[2] + spacing[2] * centerSlice[2];
>>
>> resliceAxesSagital->DeepCopy(sagitalElements);
>>
>> transformSagital->RotateX(rotate);
>>
>> reslicerSagital->SetInput(volumeData);
>> reslicerSagital->SetOutputDimensionality(2);
>> reslicerSagital->SetResliceAxes(resliceAxesSagital);
>> reslicerSagital->SetResliceAxesOrigin(positionCenter);
>> reslicerSagital->SetInterpolationModeToLinear();
>>
>> reslicerSagital->SetResliceTransform(transformSagital);
>> reslicerSagital->Update();
>> sliceImageSagital = reslicerSagital->GetOutput();
>>
>>
>> As I dsaid before the problem is that I want to rotate around the
>> center of the image and not the origin of the image.
>>
>>
>> Thanks a lot
>>
>>
>> --
>> Fabián Torres Robles
>> Maestria en Ciencias en Ingeniería Electrónica
>> Ingeniería en Sistemas Electrónicos
>> tel. 58081280, 0445534661338
>> e-mail fabian.trobles at gmail.com, dae.wong at gmail.com
>>
>
>


-- 
Fabián Torres Robles
Maestria en Ciencias en Ingeniería Electrónica
Ingeniería en Sistemas Electrónicos
tel. 58081280, 0445534661338
e-mail fabian.trobles at gmail.com, dae.wong at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160529/d07e2bbf/attachment.html>


More information about the vtkusers mailing list