[Insight-users] MaskImageFilter with VectorImage

Cory Quammen cquammen at cs.unc.edu
Wed Apr 6 22:43:02 EDT 2011


On Wed, Apr 6, 2011 at 5:47 PM, David Doria <daviddoria at gmail.com> wrote:
> On Wed, Apr 6, 2011 at 2:53 PM, brian avants <stnava at gmail.com> wrote:
>> adding the ZeroValue() function to numeric traits ( and changing the
>> initialization code ) will do the trick, compiler-wise.   but run-time
>> behavior will depend on what's done in the rest of the code.
>>
>> we used this fix for the interpolators  :
>>
>> http://review.source.kitware.com/#change,1303
>>
>> http://review.source.kitware.com/#patch,sidebyside,1303,1,Modules/Core/Common/include/itkVariableLengthVector.txx
>>
>> which may enable a similar approach for the mask filter.
>>
>> brian
>
> It now compiles this code without errors:
> http://codepad.org/kd7kKam3
>
> It seems to mostly work (i.e. pixels corresponding to zero valued mask
> pixels are set to (0,0) ), but one pixel that should be zero seems to
> be a garbage value. I'm not sure why this would be the case... any
> thoughts?

I think you need to change line 60 in your example code to

VectorImageType::PixelType outsideValue(2);
outsideValue->Fill(0);
maskFilter->SetOutsideValue(outsideValue);

itk::NumericTraits<VectorImageType::PixelType>::ZeroValue() returns a
zero-length vector. When masked pixels are assigned the outside value,
no copying occurs because the loop in the assignment operator that
does the copying iterates over the number of elements in the vector on
the right hand side, i.e., nothing gets copied. See line 234 of
http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Core/Common/include/itkVariableLengthVector.txx;h=48eda27dbdf0bdf96ae973f660450b2b6906ea40;hb=HEAD.
Thus, I expect that the garbage values you are seeing are caused by
those values never actually being assigned.

>
> http://review.source.kitware.com/#change,1338
>
> Thanks for the tips,
>
> David
>



-- 
Cory Quammen
Computer Integrated Systems for Microscopy and Manipulation (CISMM)
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen


More information about the Insight-users mailing list