[Insight-users] MaskImageFilter with VectorImage
Cory Quammen
cquammen at cs.unc.edu
Tue Apr 5 22:24:08 EDT 2011
David,
Unfortunately, it appears you cannot use the itk::MaskImageFilter on
vector images. The problem is in line 60 of itkMaskImageFilter.h, as
your error report says. The line defines the constructor as
MaskInput():m_OutsideValue(NumericTraits< TOutput >::Zero) {}
TOutput is a itk::VariableLengthVector< unsigned char, 2 >, which
means that the partial specialization of itk::NumericTraits for
itk::VariableLengthVector< T > is instantiated. In this
specialization, itk::NumericTraits<T>::Zero is a static method that
takes a reference vector pixel to determine the vector length at run
time, whereas for most built-in types itk::NumericTraits<T>::Zero is a
static member variable. Thus the complaint about not being able to
cast from a method to an unsigned int.
To make itk::MaskImageFilter work with vector images, you could write
a partial specialization of itk::Functor::MaskInput specifically for a
TOutput of type itk::VariableLengthVector< T > that doesn't have the
initialization of m_OutsideValue in the constructor definition. This
isn't ideal because it leaves the outside value uninitialized, but I
don't see what other option there is for vector images because the
vector length isn't known until run time.
Cory
On Tue, Apr 5, 2011 at 7:10 PM, David Doria <daviddoria at gmail.com> wrote:
> On Sun, Apr 3, 2011 at 12:43 PM, David Doria <daviddoria at gmail.com> wrote:
>>
>> When trying to compile this:
>>
>> #include "itkVectorImage.h"
>> #include "itkMaskImageFilter.h"
>>
>> typedef itk::VectorImage<unsigned char, 2> VectorImageType;
>> typedef itk::Image<unsigned char, 2> MaskImageType;
>>
>> int main(int argc, char *argv[])
>> {
>> typedef itk::MaskImageFilter< VectorImageType, MaskImageType >
>> MaskFilterType;
>> MaskFilterType::Pointer maskFilter = MaskFilterType::New();
>> maskFilter->Update();
>>
>> return EXIT_SUCCESS;
>> }
>>
>> I get
>> itkMaskImageFilter.h:60: error: invalid conversion from ‘const
>> itk::VariableLengthVector<unsigned char> (*)(const
>> itk::VariableLengthVector<unsigned char>&)’ to ‘unsigned int’
>> itkMaskImageFilter.h:60: error: initializing argument 1 of
>> ‘itk::VariableLengthVector<TValueType>::VariableLengthVector(unsigned
>> int) [with TValueType = unsigned char]’
>>
>> Is there any reason a VectorImage cannot be masked?
>>
>> Thanks,
>>
>> David
>
> Is there a different class to mask a VectorImage?
>
> David
>
> _____________________________________
> 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
>
>
--
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