[Insight-users] Subclassing ImageToImageFilter

Bradley Lowekamp blowekamp at mail.nih.gov
Thu May 2 09:04:58 EDT 2013


Hello,

The wiki examples are a wonderful resource put together by the community! With some very dedicated individuals.

To me is sounds like you are dealing more with 3D image of vector as opposed to 4D images. I would look into using a VectorImage for image input, this image class allows for variable number of components. For the output I'd look into an Image of FixedArray, Vector etc..

What version of ITK are you using? If you really do need true 4D images,  then some important changes have happened in ITK. Just in the past month I have modularized how image region splitting is performed in many areas of ITK include threading. Basically, there is a new ImageRegionSplitterBase[1] class that can be plugged into filter to changes how images a split for multi-threading.  The ImageRegionSplitterSlowDimension contains the code to split images that was in the ImageSource. There is now a ImageSource::GetImageRegionSplitter[3] method which returns the object used to perform the splitting for multi-threading. This can be overloaded to return the appropriate splitter object for the algorithm implemented in a filter. An example of this is in the RecursiveSeparableImageFilter[4]. It uses the ImageRegionSpliterDirection class to split is a specified direction. For yourself you could specify dimension direction 2. From there is should be easy to define the input region from the outputRegionForThread to accomplish what you wish.

Hope this bit of a tangent helps,
Brad

[1] http://www.itk.org/Doxygen/html/classitk_1_1ImageRegionSplitterBase.html
[2] http://www.itk.org/Doxygen/html/classitk_1_1ImageRegionSplitterSlowDimension.html
[3] http://www.itk.org/Doxygen/html/classitk_1_1ImageSource.html#ab009a02af33d02e6d5376cb1fb0efe05
[4] https://github.com/Kitware/ITK/blob/master/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx#L190

On May 2, 2013, at 2:32 AM, Soren Christensen <sorench at gmail.com> wrote:

> Hi,
>  I am trying to create a filter using ImageToImageFilter that I would like to be multi-threaded.
> However, I have some trouble figuring out how to get the dimensions right.
> 
> The input is 4D and I want to create an output that is also 4D, but the fourth dimension of the output will always be of constant length in the output, say L=4. (So Dim4 is a vector dim and regardless of the input length the outputs 4th dimension will have length 4).
> In ThreadedGenerateData(), I would like to just iterate spatial positions (the first 3 dimensions) so for example partition the outputRegionForThread partitioned along the 3rd dimension (although along 1 or 2nd dim would work too).
> So essentially I want to iterate over all spatial locations (dimensions 1-3), and for each spatial location grab the vector along the 4th dimension. For each location, the result (vector of length 3) is written into the 4D output.
> 
> It seems to me that once I define the output dimensions in GenerateOutputInformation() (4D), then ThreadedGenerateData() will partition THIS 4D region whereas I am looking to iterate just the first 3 dimensions of the output.
> How can I achieve this? 
> Should I be looking at using vector images for this?  Or multiple outputs?
> 
> Thanks
> Soren
> 
> 
> Btw:
> Thanks to whoever put all the examples on Wiki  - they are fantastic.
> 
> 
>   
> _____________________________________
> 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://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130502/84f974ac/attachment.htm>


More information about the Insight-users mailing list