[Insight-users] ImageRegionIterator on deformation field and mask image.

Luis Ibanez luis.ibanez at kitware.com
Tue May 25 13:39:41 EDT 2010


Hi Xi,

Thanks for your detailed message and for
providing the link to your source code and
input data.

I managed to build and run your code without
any problem.

I uploaded the masked deformation field into
ParaView (www.paraview.org) and verified that
the region inside of the mask is actually set to
a constant vector value.


    In short:    Your code works for me.


--

I'm wondering about the method that you are
using for evaluating the deformed image ?

maybe you are using a misleading visualization ?

....

In any case, from what I can see,
your code works correctly.

At least for the purpose of setting to an
average value the pixels of a deformation
field that are inside a given mask.

(Your code doesn't include the part
that will load an input image and warp
it by using the deformation field).



    Regards,


           Luis



--------------------------------------------------------------
On Wed, May 12, 2010 at 10:23 PM, Xi Liang <liangxi1986317 at hotmail.com> wrote:
> Dear all,
> I have a deformation field of size 128 X 128 X 124 (vector is 3D), and a
> mask image of size 128 X 128 X 124. I use a ImageRegionIterator on each of
> them. The purpose is to assigned the masked region in deformation field to
> its mean value. The following is how I do it:
>
> I first set up 2 iterators, one for deformation field, one for mask image.
> Size the size of these two images are the same. So I use mask image iterator
> to find the corresponding deformation field pixel. Then I calculate the mean
> value of the masked deformation field region. At the end I start over again
> to assign the mean value to the masked region and get a new deformation
> field.
> By doing so, if I apply the new deformation field on the mask used before, I
> expect the mask image will not be nonrigidly deformed, since for only
> translation should happen on the masked area. However, this does not happen.
> Is there anything wrong here?
> The core code is at the end of the email, I also put on the code an testing
> image at
> :http://www.mediafire.com/file/wyzvkdnhnmo/MeanDeformationFieldCode.zip
>
>   /** Setup iterator over outputtmp. */
>   itk::ImageRegionIterator< DeformationFieldType >       oit(
>     outputtmp, outputtmp->GetLargestPossibleRegion() );
>
>   /** Set iterator over mask image */
>   itk::ImageRegionIterator< MaskImageType >       mit(
>     maskImage, maskImage->GetLargestPossibleRegion() );
>   oit.GoToBegin();
>   mit.GoToBegin();
>
>
>
>     /** The actual work. */
>   while ( !oit.IsAtEnd() ) {
>  /** add the vector value within the mask **/
>  if ( mit.Get() > 0.000001 ) {
>  sum += oit.Get();
>  sumc++;
>  }
>  ++oit;
>  ++mit;
>   }
>
>   /** Get the mean value*/
>   VectorType mean = sum / sumc;
>
>
>
>   oit.GoToBegin();
>   mit.GoToBegin();
>   /* Copy value */
>   while ( !oit.IsAtEnd() )
>   {
>  if ( mit.Get() > 0.000001 ) {
>  oit.Set( mean );
>  }
>  ++mit;
>  ++oit;
>   }
> _____________________________________
> 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
>
>


More information about the Insight-users mailing list