Itk orientimagefilter

I’m trying to set the coordinate orientation for around 350 images using orientor filter the updation of this filter is taking around 19s for execution

Is there a way to reduce this time /any alternate filter.
Piece of code is attached below

itk::orientimagefilter<Projectionstype,projectionstype>::pointer orientor=Itk::orientimagefilter<projectionstype,projectionstype>::New();
orientor->setgivencoordinateorientation(itk::spatialorientation::ITK_COORDINATE_ORIENTATION_RSP)
Orientor->update
Projectionstype is a image of unsigned short type and dimension 3

I assume that your pipeline is read → orient → write. If you enabled compression for writing, that might be the slow step. If your images are big and your hard disk slow, that might be the reason. Finally, make sure you are not compiling your program using Debug settings. That is at least a few times slower than, say, RelWithDebInfo.

1 Like

Thanks for your reply!!
Release mode is being used to run the program, images are of size 1536*1536.Is there any gpu support available in itk for orientor filter?

Your timing is suspicious to me. Please see the following time profiling with SimpleITK:

In [5]: img = sitk.Image([1536,1536,128], sitk.sitkUInt16)

In [6]: sitk.DICOMOrient( img, "LPS")
Out[6]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b4d4b0> >

In [7]: %time
CPU times: user 2 µs, sys: 0 ns, total: 2 µs
Wall time: 5.25 µs

In [8]: %time sitk.DICOMOrient( img, "LPS")
CPU times: user 199 ms, sys: 631 ms, total: 830 ms
Wall time: 331 ms
Out[8]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b38270> >

In [9]: %time sitk.DICOMOrient( img, "RPS")
CPU times: user 489 ms, sys: 1.43 s, total: 1.92 s
Wall time: 777 ms
Out[9]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f09131b0> >

In [10]: %time sitk.DICOMOrient( img, "RSP")
CPU times: user 2.59 s, sys: 1.73 s, total: 4.32 s
Wall time: 387 ms
Out[10]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b53510> >

In [11]: %time sitk.DICOMOrient( img, "LIA")
CPU times: user 2.87 s, sys: 1.7 s, total: 4.56 s
Wall time: 527 ms
Out[11]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b40420> >

In [12]: sitk.ProcessObject_SetGlobalDefaultNumberOfThreads(1)

In [13]: %time sitk.DICOMOrient( img, "LPS")
CPU times: user 169 ms, sys: 146 ms, total: 315 ms
Wall time: 319 ms
Out[13]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8e0448a20> >

In [14]: %time sitk.DICOMOrient( img, "RPS")
CPU times: user 384 ms, sys: 403 ms, total: 787 ms
Wall time: 1.05 s
Out[14]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b65150> >

In [15]: %time sitk.DICOMOrient( img, "LIA")
CPU times: user 1.45 s, sys: 586 ms, total: 2.03 s
Wall time: 2.05 s
Out[15]: <SimpleITK.SimpleITK.Image; proxy of <Swig Object of type 'std::vector< itk::simple::Image >::value_type *' at 0x7fc8f1b01600> >

The DICOMOrientImageFilter is the same algorithm as OrientImage but with DICOM naming conventions for orientation.

The timing above indicates that the filter takes ~.5 seconds with the default multi-threading and ~1-2 seconds for a single thread.

A GPU is not going to help for the flipping and axis permutations operations of moving pixels around.

1 Like