Hi Itk-users,<br>
<br>After my message to Luis (please see below) I&#39;ve found a way to create vector samples from different image contrasts by using the itk::FixedArray class. <br><br>However, in addition to my previous question (which still remains) about how to use the &quot; ImageToVectorImageFilter + ImageToListAdaptor &quot; to to build vector samples (as performed with the itk::FixedArray), I do have another question.  <br>
<br>Is there any way to define the number of contrasts (as used in the line typedef itk::FixedArray&lt; TInputPixelType, NumberOfContrasts &gt; TMeasurementVectorType; ) in the running time ? <br><br>Thank you again,<br><br>
Ricardo<br><br><br>   <br>///<br>const int NumberOfContrasts = 1; //3;<br>const int Dimension = 3;<br><br>/// Pixel type definition<br>typedef signed short                                                    TInputPixelType;<br>
typedef signed short                                                    TOutputPixelType;<br><br>/// Define type of the input and output images<br>typedef itk::Image&lt; TInputPixelType, Dimension &gt;                         TInputImageType;<br>
typedef itk::Image&lt; TOutputPixelType, Dimension &gt;                         TOutputImageType;<br><br><br>    typedef itk::FixedArray&lt; TInputPixelType, NumberOfContrasts &gt; TMeasurementVectorType;<br>    typedef itk::Image&lt; TMeasurementVectorType, Dimension &gt; TArrayImageType;<br>
<br>    typedef itk::ScalarToArrayCastImageFilter&lt; TInputImageType, TArrayImageType &gt; CasterType;<br>    CasterType::Pointer caster = CasterType::New();<br>    caster-&gt;SetInput( 0, img );<br>    caster-&gt;Update();<br>
<br>    typedef itk::Statistics::ImageToListAdaptor&lt; CasterType::OutputImageType &gt; ImageToListAdaptorType;<br>    ImageToListAdaptorType::Pointer adaptor = ImageToListAdaptorType::New();<br>    adaptor-&gt;SetImage( caster-&gt;GetOutput() );<br>
<br>    ///<br>    /// Create the GMM<br>    ///<br>    TGMM&lt; TArrayImageType, TOutputImageType &gt; gmm;<br>    gmm.SetInputArrayImage( caster-&gt;GetOutput() );<br><br><br><br><br>-----<br>Hi Luis,<br><br>
I am trying to use the two following itk classes to get Vector Samples into<br>
an Gaussian Mixture Model classifier. Although, I am following your<br>
suggestion (please see<br>
<a href="http://www.cmake.org/pipermail/insight-users/2007-April/022003.html" target="_blank">http://www.cmake.org/pipermail/insight-users/2007-April/022003.html</a> ) I am<br>
still getting an error.<br>
<br>
I really appreciate if you could help on this.<br>
<br>
Thanks,<br>
Ricardo<br>
<br>
<br>
<br>
#include &quot;io.h&quot;<br>
#include &quot;itkImageToVectorImageFilter.<div id=":7d" class="ii gt">h&quot;<br>
#include &quot;itkScalarToArrayCastImageFilter.h&quot;<br>
#include &quot;itkImageToListAdaptor.h&quot;<br>
<br>
/// Pixel type definition<br>
typedef signed short<br>
                  TInputPixelType;<br>
<br>
/// Define type of the input and output images<br>
typedef itk::Image&lt; TInputPixelType, Dimension &gt;<br>
TInputImageType;<br>
<br>
<br>
///<br>
/// Main function<br>
///<br>
int main( int argc, char **argv )<br>
{<br>
    // Read a minc image<br>
    TInputImageType::Pointer img = ReadMincImage&lt; TInputImageType &gt;(<br>
&quot;test.mnc&quot; );<br>
<br>
    typedef itk::ImageToVectorImageFilter&lt; TInputImageType &gt;<br>
ImageToVectorImageFilterType;<br>
    ImageToVectorImageFilterType::Pointer vectorImage =<br>
ImageToVectorImageFilterType::New();<br>
    vectorImage-&gt;SetNthInput( 0, img );<br>
    vectorImage-&gt;Update();<br>
<br>
    typedef itk::Statistics::ImageToListAdaptor&lt;<br>
ImageToVectorImageFilterType::OutputImageType &gt; ImageToListAdaptorType;<br>
    ImageToListAdaptorType::Pointer adaptor = ImageToListAdaptorType::New();<br>
    adaptor-&gt;SetImage( vectorImage-&gt;GetOutput() );<br>
<br>
    return 0;<br>
}<br>
<br>
<br>
[100%] Building CXX object<br>
segmentation/gmm/CMakeFiles/gmm_classifier.dir/main.cpp.o<br>
In file included from<br>
/usr/local/include/InsightToolkit/Common/itkConceptChecking.h:23,<br>
                 from<br>
/usr/local/include/InsightToolkit/Common/itkImageHelper.h:20,<br>
                 from<br>
/usr/local/include/InsightToolkit/Common/itkImageBase.h:35,<br>
                 from<br>
/usr/local/include/InsightToolkit/Common/itkImage.h:20,<br>
                 from /home/ferrari/Workspace/MIP_PROJECTS/trunk/io/io.h:6,<br>
                 from<br>
/home/ferrari/Workspace/MIP_PROJECTS/trunk/segmentation/gmm/main.cpp:2:<br>
/usr/local/include/InsightToolkit/Common/itkPixelTraits.h: In instantiation<br>
of ?itk::PixelTraits&lt;itk::VariableLengthVector&lt;short int&gt; &gt;?:<br>
/usr/local/include/InsightToolkit/Numerics/Statistics/itkImageToListAdaptor.h:97:<br>
instantiated from<br>
?itk::Statistics::ImageToListAdaptor&lt;itk::VectorImage&lt;short int, 3u&gt;,<br>
itk::VariableLengthVector&lt;short int&gt; &gt;?<br>
/home/ferrari/Workspace/MIP_PROJECTS/trunk/segmentation/gmm/main.cpp:51:<br>
instantiated from here<br>
/usr/local/include/InsightToolkit/Common/itkPixelTraits.h:41: error:<br>
?Length? is not a member of ?itk::VariableLengthVector&lt;short int&gt;?<br>
In file included from<br>
/home/ferrari/Workspace/MIP_PROJECTS/trunk/segmentation/gmm/main.cpp:8:<br>
/usr/local/include/InsightToolkit/Numerics/Statistics/itkImageToListAdaptor.h:<br>
In member function ?const TMeasurementVector&amp;<br>
itk::Statistics::ImageToListAdaptor&lt;TImage,<br>
TMeasurementVector&gt;::GetMeasurementVector(const typename<br>
TImage::PixelContainer::ElementIdentifier&amp;) const [with TImage =<br>
itk::VectorImage&lt;short int, 3u&gt;, TMeasurementVector =<br>
itk::VariableLengthVector&lt;short int&gt;]?:<br>
/home/ferrari/Workspace/MIP_PROJECTS/trunk/segmentation/gmm/main.cpp:56:<br>
instantiated from here<br>
/usr/local/include/InsightToolkit/Numerics/Statistics/itkImageToListAdaptor.h:323:<br>
warning: taking address of temporary<br>
/usr/local/include/InsightToolkit/Numerics/Statistics/itkImageToListAdaptor.h:323:<br>
warning: returning reference to temporary<br>
make[2]: *** [segmentation/gmm/CMakeFiles/gmm_classifier.dir/main.cpp.o]<br>
Error 1<br>
make[1]: *** [segmentation/gmm/CMakeFiles/gmm_classifier.dir/all] Error 2<br>
make: *** [all] Error 2</div>