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

Xi Liang liangxi1986317 at hotmail.com
Wed May 12 22:23:28 EDT 2010


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;
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100513/16c0aef9/attachment-0001.htm>


More information about the Insight-users mailing list