[Insight-users] vector image processing

Luis Ibanez luis.ibanez at kitware.com
Tue Mar 16 15:08:47 EDT 2010


Hi Christina,

Given that your process is so specific, it turns out to be a lot easier
to customize a filter for doing exactly what you want, instead of
combining existing filters.

Please find attached a filter based on the BinaryFunctorImageFilter.

This attached filter takes two input images. One is expected to be
an RGB image, and the other a scalar image. The filter will compute
the absolute values of the rgb components and will multiply them
by the values of the scalar image (all this pixel-wise).

The key part of the code is the implementation of the Functor,
that is the class defining the operation to be performed on
every pixel of the image:


  inline TOutput operator()( const TInput1 & A, const TInput2 & B) const
    {
    TOutput output;
    const unsigned int numberOfComponents =
Statistics::MeasurementVectorTraits::GetLength(A);
    for( unsigned int cc = 0; cc < numberOfComponents; cc++ )
      {
      output[cc] = (A[cc] > 0) ? A[cc] : -A[cc];
      output[cc] *= B;
      }
    return output;
    }


The entire filter is defined in a single header  file,
given that the rest of functionalities are inherited
from the base class.


They include:

 * Support for multi-threading and
 * Support for streaming.

You will also find attached a test for running
the filter (along with a CMakeLists.txt for
configuring their build).


For more details on how to write new ITK filters
you may want to look at the Tutorial:

http://www.na-mic.org/Wiki/images/b/bc/Insight-Writing-a-New-Filter.ppt


Please give it a try at the attached code and let
us know if you have any questions.


     Thanks


           Luis


--------------------------------------------------------------------------------
On Fri, Mar 12, 2010 at 4:54 AM, Chr. Rossmanith
<cr at neuro.ma.uni-heidelberg.de> wrote:
> Hi,
>
> I'd like to do a componentwise abs() of a vector valued image volume and
> multiply it with a scalar image and save the result as 2D RGB images. I'm
> unsure about the best way to do this.
>
> What I've done so far:
>
> read scalar image using ImageFileReader
> read vector image using ImageFileReader
> use VectorIndexSelectionCastImageFilter to extract each of the three
> components
> use AbsImageFilter on the components
> use MultiplyImageFilter on that result and the scalar image
> use ImageToVectorImageFilter to arrange the the scalar results into a vector
>
> At this stage there rises a big '?'. How do I switch from vector to rgb?
>
> The last steps are:
>
> NumericSeriesFileNames for file name creation
> ImageSeriesWriter to create PNGs
>
> My first idea was to use a VectorToRGBImageAdaptor but then I've read that
> it's not possible to connect an adaptor to an image writer.
>
> Any hint is welcome.
>
> Thank you,
> Christina Rossmanith
> _____________________________________
> 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 --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)


PROJECT(AbsoluteMultiplyFilter)

FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(AbsoluteMultiplyFilter itkMultiplyAbsoluteVectorByScalarImageFilterTest.cxx )

TARGET_LINK_LIBRARIES(AbsoluteMultiplyFilter ITKIO ITKStatistics ITKCommon)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkMultiplyAbsoluteVectorByScalarImageFilterTest.cxx
Type: text/x-c++src
Size: 2406 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100316/30144f32/attachment-0001.cxx>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkMultiplyAbsoluteVectorByScalarImageFilter.h
Type: text/x-chdr
Size: 3565 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100316/30144f32/attachment-0001.h>


More information about the Insight-users mailing list