[ITK-users] [ITK] Rotate image

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Jul 3 13:51:20 EDT 2014


Hello Elena,

After looking at your images, I realized you may be interested in Oriented Bounding Box computation.

I have an external ITK module[1] which computes OBBs in the LabelMap infrastructure. One way it presents the OBB is as an origin and Direction[2]. This information is then passed to the Resample filter to extract the OBB[3].

You may be able to re-use the code in this module or find another way to compute your origin and direction based on information specific for you application.

Hope this helps,
Brad


[1] https://github.com/blowekamp/itkOBBLabelMap
[2] https://github.com/blowekamp/itkOBBLabelMap/blob/master/include/itkOrientedBoundingBoxLabelObject.h#L91-L111
[3] https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOrientedBoundingBoxLabelMapFilterTest2.cxx#L94-L113

On Jul 3, 2014, at 12:52 PM, Nicolas Gallego <nicgallego at gmail.com> wrote:

> Hi Elena,
> 
> If I understand well your task, you have the rotation angle and translation parameters and you would like to transform your image parallel to the cartesian coordinate system and crop/resample it?
> 
> Conceptually then you could proceed as follows:
> 
> 1. Create a rigid transformation with given angle and translation in 2D [1]  or 3D [2]
> 
> 2. Apply the transformation to your image via an interpolator and a resampler, like illustrated in the Software Guide Section 8.2 [3]
> 
> 3. The resampler interface lets you specifiy all the image information for the output:
> region( start, size)
> spacing
> origin
> direction
> 
> Connect everything and update and that should do the job, 
> 
> Pay attention to the center of rotation, the example you cite uses the center of the image as center of rotation, that should be fine.
> 
> I would proceed like that, I am not aware of a filter to do this automatically. 
> 
> If you don't know a priori the rigid transformation parameters to apply, then a registration algorithm can be used to estimate them.
> 
> [1] http://www.itk.org/Doxygen45/html/classitk_1_1Rigid2DTransform.html
> [2] http://www.itk.org/Doxygen45/html/classitk_1_1Rigid3DTransform.html
> [3] http://www.itk.org/ItkSoftwareGuide.pdf
> 
> hope that helps
> 
> Nicolás Gallego-Ortiz
> Université catholique de Louvain, Belgium
> 
> 
> 2014-07-03 16:16 GMT+02:00 elena bresciani <elena.bresciani87 at gmail.com>:
> Hello guys,
> 
> I need help on image rotation. I have two questions:
> 
> 1 - how can I modify the code in ResampleImageFilter4.cxx to make the size of the output image following the rotation? More specifically: if image size is Size X >> Size Y and I want a 90° rotation the result (using the code in the example without modifications) is cropped because the new image has now Size Y >> Size X but in the example this is not taken into account. I know I could use Permute Axis but I would like to write something that works both for 90 and 180 degrees rotations. 
> 
> 2 - I would like to do something like in the scheme attached. Actually, as shown I've reached my goal only partially using AutoCropLabelMapFilter. There is a simple way of doing what I want or I have to compute the angle of inclination of my region of interest and rotate and crop accordingly? Images are not binary!
> 
> Thanks in advance!
> 
> Elena
> 
> _____________________________________
> 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.php
> 
> 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://public.kitware.com/mailman/listinfo/insight-users
> 
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
> 
> 
> _____________________________________
> 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.php
> 
> 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://public.kitware.com/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20140703/7ce6a473/attachment-0001.html>


More information about the Insight-users mailing list