[vtkusers] Rotate vtkImage with vtkmatrix4x4

Jothy jothybasu at gmail.com
Tue Mar 1 13:29:42 EST 2011


Yes I have seen this before.I will use it when I add contours.

Thanks

Jothy

On Tue, Mar 1, 2011 at 6:10 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> About contours appearing behind the image... I forgot to comment on that.
> Look at the documentation for vtkMapper::SetResolveCoincidentTopology()
> to see how to make actors appear in front of the image.
>
> Another trick is to apply vtkTubeFilter after vtkCutter, in order to give
> your
> contour lines a finite thickness.
>
>  - David
>
>
> On Tue, Mar 1, 2011 at 10:45 AM, David Gobbi <david.gobbi at gmail.com>
> wrote:
> > Hi Jothy,
> >
> > If you work with sagittal and coronal image you will have to worry about
> > image orientation, but with axial images everything is identity.
> >
> > For axial images, just make sure that your camera ViewUp is (0, -1, 0)
> > and DirectionOfProjection is (0, 0, 1).  The direction of projection for
> > the camera is the (FocalPoint - Position) direction.
> >
> >  - David
> >
> >
> > On Tue, Mar 1, 2011 at 10:36 AM, Jothy <jothybasu at gmail.com> wrote:
> >> Hi David,
> >>
> >> I have given up using vtkImageViewer2 right from the beginign of this
> >> project!
> >>
> >> Since it has problem with actors with varying z position - if your
> actors
> >> are from cutter ( some go behind the viewer).I am using vtkImageActor
> with
> >> vtkImageMapToColors and vtkImageReslice.
> >>
> >> The match between the dose and CT is perfect, except the view is upside
> >> down.
> >>
> >> So you mean there is no point in setting rotation and instead use the
> camera
> >> orientation.
> >>
> >> Thanks
> >>
> >> Jothy
> >>
> >> On Tue, Mar 1, 2011 at 5:26 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
> >>>
> >>> Hi Jothy,
> >>>
> >>> If your ImageOrientationPatient is 1 0 0 0 1 0 then the direction
> >>> cosines will be the identity matrix.
> >>>
> >>> So the image is fine, my guess is that vtkImageViewer2 is the
> >>> problem.  As I've said in other emails, I never use vtkImageViewer2.
> >>> But digging into its code, I see this:
> >>>
> >>>      case vtkImageViewer2::SLICE_ORIENTATION_XY:
> >>>        cam->SetFocalPoint(0,0,0);
> >>>        cam->SetPosition(0,0,1); // -1 if medical ?
> >>>        cam->SetViewUp(0,1,0);
> >>>        break;
> >>>
> >>> This view orientation is NOT the proper axial orientation for
> >>> DICOM patient coordinates.  In DICOM, Y increases in the
> >>> A-P direction (top-down), but vtkImageViewer2 has Y increase
> >>> from bottom to top.
> >>>
> >>> I suggest that you give up on vtkImageViewer2.  As I've said
> >>> before, I always use vtkImageActor to display images, and I
> >>> set the camera orientation myself.  And I use FileLowerLeftOn.
> >>>
> >>> And it is moot now, but the math here is incorrect:
> >>>  reslice->SetElement(0,3,IPP[0]);
> >>>  reslice->SetElement(1,3,IPP[1]);
> >>>  reslice->SetElement(2,3,IPP[2]);
> >>>
> >>> This applies a translation by IPP after the rotation, which is
> >>> not the same thing as rotating about IPP.
> >>>
> >>>  - David
> >>>
> >>>
> >>>
> >>> On Tue, Mar 1, 2011 at 9:58 AM, Jothy <jothybasu at gmail.com> wrote:
> >>> > Yes it doesn't rotate at all!
> >>> >
> >>> > My axial elements were
> >>> >
> >>> > reslice->DeepCopy( imageReader->GetDirectionCosines());
> >>> > reslice->SetElement(0,3,IPP[0]);
> >>> > reslice->SetElement(1,3,IPP[1]);
> >>> > reslice->SetElement(2,3,IPP[2]);
> >>> >
> >>> > My images have
> >>> >
> >>> > Image position: -275 -524 -122.441
> >>> > Image Dims: 512 512 98
> >>> > Image Origin: -275 -524 -122.441
> >>> > ImageOrient: 1 0 -1.22465e-16 0 1 0
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > But this is changing only the y axis (some translation in Y). But no
> >>> > rotation.
> >>> >
> >>> > Any help is greatly appreciated.
> >>> >
> >>> > Thanks again
> >>> >
> >>> > Jothy
> >>> >
> >>> > On Tue, Mar 1, 2011 at 4:42 PM, David Gobbi <david.gobbi at gmail.com>
> >>> > wrote:
> >>> >>
> >>> >> Hi Jothy,
> >>> >>
> >>> >> When you say "doesn't rotate the image", do you mean that it does
> >>> >> nothing at all?  What are the elements of your direction cosines
> >>> >> matrix?
> >>> >>
> >>> >> Also, note that direction cosines matrix is a pure rotation matrix.
> >>> >> i.e. it rotates about (0,0,0).  You need to create a matrix that
> >>> >> rotates around a particular point in space.
> >>> >>
> >>> >>  - David
> >>> >>
> >>> >>
> >>> >> On Tue, Mar 1, 2011 at 9:28 AM, Jothy <jothybasu at gmail.com> wrote:
> >>> >> > Thanks!
> >>> >> >
> >>> >> > Now my images appeasr like the one shown in figure.
> >>> >> >
> >>> >> > I need to rotate the image and dose about the ImagePositionPatient
> >>> >> > upside-down.
> >>> >> >
> >>> >> > I tried vtkImageFlip - it invalidates the dicom coordinate system
> and
> >>> >> > the
> >>> >> > dose and image doesn't match.
> >>> >> >
> >>> >> > I tried this
> >>> >> >
> >>> >> >       vtkMatrix4x4 *invert = vtkMatrix4x4::New();
> >>> >> >
> >>> >> >         invert->DeepCopy( imageReader->GetDirectionCosines());
> >>> >> >
> >>> >> >         invert->Invert();
> >>> >> >
> >>> >> >         vtkImageReslice *reslice = vtkImageReslice::New();
> >>> >> >
> >>> >> >         reslice->SetResliceAxes( invert );
> >>> >> >
> >>> >> >         reslice->SetInput(this->imageData);
> >>> >> >
> >>> >> >         reslice->Update();
> >>> >> >
> >>> >> >
> >>> >> > But it doesn't rotate the image.How to rotate the image?
> >>> >> >
> >>> >> > Thanks
> >>> >> >
> >>> >> > Jothy
> >>> >> >
> >>> >> >
> >>> >> > On Tue, Mar 1, 2011 at 4:07 PM, Jothy <jothybasu at gmail.com>
> wrote:
> >>> >> >>
> >>> >> >> But in this example FileLowerLeft is switched off.
> >>> >> >>
> >>> >> >> Thanks
> >>> >> >>
> >>> >> >> Jothy
> >>> >> >>
> >>> >> >> On Tue, Mar 1, 2011 at 3:50 PM, Mathieu Malaterre
> >>> >> >> <mathieu.malaterre at gmail.com> wrote:
> >>> >> >>>
> >>> >> >>> jothy, I think what you are looking for is already in gdcm, have
> a
> >>> >> >>> look
> >>> >> >>> at:
> >>> >> >>> gdcmreslice.cxx
> >>> >> >>>
> >>> >> >>> hth
> >>> >> >>> On Tue, Mar 1, 2011 at 4:31 PM, Jothy <jothybasu at gmail.com>
> wrote:
> >>> >> >>> > Hi all,
> >>> >> >>> >
> >>> >> >>> > I am trying to rotate vtkImageData using vtkMatrix4x4 about a
> >>> >> >>> > point.
> >>> >> >>> > is
> >>> >> >>> > there any example on how to do this?
> >>> >> >>> >
> >>> >> >>> > Thanks
> >>> >> >>> >
> >>> >> >>> > Jothy
> >>> >> >>> >
> >>> >> >>> > _______________________________________________
> >>> >> >>> > 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
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>>
> >>> >> >>>
> >>> >> >>>
> >>> >> >>> --
> >>> >> >>> Mathieu
> >>> >> >>
> >>> >> >
> >>> >> >
> >>> >> > _______________________________________________
> >>> >> > 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/20110301/63a8c0ce/attachment.htm>


More information about the vtkusers mailing list