[Insight-users] Convert image's direction cosines to transform matrix

Luis Ibanez luis.ibanez at kitware.com
Wed Apr 28 00:16:04 EDT 2010


Hi Dženan

This is indeed a common problem,
so, it is great that you bring it up.


Following the numbering of your questions:

a) No, there is no direct way of forcing the direction
    matrix to be an identity. (and if there was such
    method we will strongly discourage you from using it)

b)  You can change the direction matrix of the image,
     by using the ChangeImageInformationFilter.
     (but we strongly discourage you from doing so).

c)  The RIGHT thing to do is to use the direction
     matrix to correct the orientation of the isosurface
     after you extract it.  In that way, the iso-surface
     will occupy the same coordinate system as the
     original image.


Options (a) and (b) are VERY dangerous if you are
dealing with real patient data.


Please find attached an example of how to do this
with ITK and VTK. You could directly use this example,
or you can probably follow the math and apply the
equivalent processing using OSG.


You will find the full source code at:

               InsightApplications/Auxiliary/vtk




      Regards,


             Luis


---------------------------------------------------------------------
2010/4/27 Dženan Zukić <dzenanz at gmail.com>

> Hi everybody,
>
> I guess someone has dealt with a problem similar to mine before. I am doing
> segmentation in a magnetic resonance image. The result of my segmentation is
> a polygonal model. Problem: How to visualize the resulting polygonal model
> along with scalar-field image?
>
> I use Qt, ITK and OpenSceneGraph. First I tried using osgVolume
> (ray-casting renderer) together with polygonal data in the same scene, but
> with that setup the depth information is lost. I resorted to using
> isosurface of the image instead of the image itself. It works, but I have to
> manage physical coordinates by myself - which is both a reinvention of the
> wheel and error-prone.
>
> So I decided to use ITK's physical coordinate managing routines
> (TransformPhysicalPointToIndex), but I ran into a problem. GetDirection does
> not return identity matrix for my images (at least not for sagittal ones),
> therefore my segmented parts end up displayed *outside* of the image.
> a) Is there a way to force image reading routines to load images into
> memory in such a way to have an identity matrix for directions?
> b) If not, is there a way to transform image data (using a filter) to get
> an image with identity matrix as "directions". Is that
> filter ChangeInformationImageFilter?
> c) What is the proper way to construct a transformation matrix to be
> applied to the isosurface of the image (which was generated assuming
> identity matrix directions) in order to bring it to same coordinates I get
> when using TransformIndexToPhysicalPoint? Just using matrix returned
> by GetDirection and adding translation to account for origin does not work.
>
> If anyone knows a better way to visualize a polygonal model alongside 3D
> image, I would like to hear it.
> Off topic question: is combining polygons with scalar fields so simple in
> VTK to justify a switch from OSG to VTK?
>
> Thanks to anyone who takes interest in this.
>
> Best regards,
> Dženan
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100428/d259e16e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExtractIsoSurface.cxx
Type: text/x-c++src
Size: 4222 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100428/d259e16e/attachment-0001.cxx>


More information about the Insight-users mailing list