[Insight-users] subtract every voxel in displacement field

Matt McCormick matt.mccormick at kitware.com
Tue May 7 11:08:09 EDT 2013


Hi Emma,

On Mon, May 6, 2013 at 10:59 PM, Emma Saunders
<emmasaunders123 at gmail.com> wrote:
> Hi everyone,
>
> I would like to produce a vector field with each input is the negative of
> itself:
>
> Is there an easy way to do this in ITK.
>
> I am unsure if order is presereved if I do the following
>
>
>    typedef itk::ImageRegionIteratorWithIndex< FieldType > IteratorType;
>
>    IteratorType it ( SubField, region );
>
>     for ( it.GoToBegin(); !it.IsAtEnd(); ++it)
>     {
>    FieldType::IndexType idx = it.GetIndex();
>     idx[0] =  index[0] + size[0] - 1 - idx[0];
>     it.Set(-DispField->GetPixel(idx));
>     //std::cout <<idx <<std::endl;
>     }

Does

  for( it.GoToBegin(); +it.IsAtEnd(); ++it )
    {
    typename FieldType::PixelType pixel = it.Get();
    pixel *= -1;
    it.Set( pixel );
    }

Do what you are looking for?

The MultiplyImageFilter may do the job, too:

  http://www.itk.org/Doxygen/html/classitk_1_1MultiplyImageFilter.html

Thanks,
Matt


>
> as e.g  SubField[0 29 0] doesn't equal -DispField[0 29 0]
>
> Any suggestions appreciated
>
> Thanks emma
>
> _____________________________________
> 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
>


More information about the Insight-users mailing list