[vtkusers] Image "swimming" with vtkImagePlaneWidget?

Cory Quammen cquammen at cs.unc.edu
Thu Jul 12 16:46:34 EDT 2012


[bringing in the VTK developers list]

I found some suspect code in vtkImagePlaneWidget.cxx:

1661   double planeOrigin[4];
1662   this->PlaneSource->GetOrigin(planeOrigin);
1663
1664   planeOrigin[3] = 1.0;
1665   double originXYZW[4];
1666   this->ResliceAxes->MultiplyPoint(planeOrigin, originXYZW);
1667
1668   this->ResliceAxes->Transpose();
1669   double neworiginXYZW[4];
1670   this->ResliceAxes->MultiplyPoint(originXYZW, neworiginXYZW);
1671
1672   this->ResliceAxes->SetElement(0,3,neworiginXYZW[0]);
1673   this->ResliceAxes->SetElement(1,3,neworiginXYZW[1]);
1674   this->ResliceAxes->SetElement(2,3,neworiginXYZW[2]);
1675
1676   this->Reslice->SetResliceAxes(this->ResliceAxes);

For reasons I don't understand, the origin of the plane is transformed
by the ResliceAxes transformation matrix, then the result is then
multiplied back through the transpose of the ResliceAxes matrix,
which, if I'm not mistaken, should be the inverse of the matrix if it
is orthonormal (which it appears to be). That means the neworiginXYZW
should be equivalent to planeOrigin and we can skip all the calls to
MultiplyPoint(). The swimming, I guess, results from numerical error
in the forward and inverse matrix transforms of the plane origin.

I suspect the code should be

double planeOrigin[4];
this->PlaneSource->GetOrigin(planeOrigin);
planeOrigin[3] = 1.0;

this->ResliceAxes->Transpose();

this->ResliceAxes->SetElement(0,3,planeOrigin[0]);
this->ResliceAxes->SetElement(1,3,planeOrigin[1]);
this->ResliceAxes->SetElement(2,3,planeOrigin[2]);

this->Reslice->SetResliceAxes(this->ResliceAxes);

If I change the code to the above, the swimming no longer occurs.

I'll submit a gerrit patch if my proposed fix looks reasonable.

Thanks,
Cory

On Thu, Jul 12, 2012 at 3:03 PM, Cory Quammen <cquammen at cs.unc.edu> wrote:
> By the way, I'm building VTK from git commit
>
> 2d86fe9782e36e6a5efad240bc5acef746f058ab
>
> which was created June 29, 2012.
>
> Thanks,
> Cory
>
> On Thu, Jul 12, 2012 at 2:55 PM, Cory Quammen <cquammen at cs.unc.edu> wrote:
>> Hi all,
>>
>> I'm using vtkImagePlaneWidget in an application and I noticed a
>> problem when rotating the widget. The image appears to "swim" relative
>> to the widget plane when rotating the plane, jumping around in
>> seemingly random directions rather than varying smoothly as the plane
>> is rotated. In-plane and out-of-plane translation seems fine, as does
>> resizing the plane. I see this problem on both a Mac with an AMD
>> graphics card and a Windows laptop with an NVIDIA GPU.
>>
>> Has anyone else seen this behavior?
>>
>> Thanks,
>> Cory
>>
>> --
>> Cory Quammen
>> Research Associate
>> Department of Computer Science
>> The University of North Carolina at Chapel Hill
>
>
>
> --
> Cory Quammen
> Research Associate
> Department of Computer Science
> The University of North Carolina at Chapel Hill



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill



More information about the vtkusers mailing list