Hello all,<br><br>I&#39;m stumped, and I&#39;m not exactly sure of what the core problem is. I&#39;m working on multi-spectral 2D data, where each spectral band is stored as a separate file. To import them into my ITK program, I&#39;m using the ImageToVectorImageFilter. The output of the filter is apparently a VectorImage.
<br><br>Whenever I try to use a filter that expects a Vector based image on the output, I get <a href="http://public.kitware.com/pipermail/insight-users/2007-June/022631.html">problems</a>. Am I supposed to be able to use the output of ImageToVectorImageFilter with other filters? Are there other ways of creating a multi-spectral image from multiple files? Are there ways of converting a VectorImage to a regular Image that has a Vector as it&#39;s pixel type?
<br><br>At this point, even just a few educated guesses as to what I should try would be helpful.<br><br>Is my syntax just flawed? I&#39;m trying to do it like this:<br><br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;
itkImageToVectorImageFilter.h&quot;<br>#include &quot;itkKLMRegionGrowImageFilter.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br><br>int main( int argc, char ** argv )<br>{<br>&nbsp;&nbsp;&nbsp; if( argc &lt; 5 )<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;
<br>&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; input1 input2 input3 output&quot; &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; /* Establish input image types */<br>&nbsp;&nbsp;&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp; GrayPixelType;
<br>&nbsp;&nbsp;&nbsp; const unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageDimension = 2;<br>&nbsp;&nbsp;&nbsp; typedef&nbsp;&nbsp; itk::Image&lt; GrayPixelType,&nbsp; ImageDimension &gt;&nbsp;&nbsp;&nbsp; GrayImageType;<br>&nbsp;&nbsp;&nbsp; typedef itk::ImageFileReader&lt; GrayImageType &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReaderType;
<br><br>&nbsp;&nbsp;&nbsp; /* create 3 readers, one for each spectral band */<br>&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader1 = ReaderType::New();<br>&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader2 = ReaderType::New();<br>&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader3 = ReaderType::New();
<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; reader1-&gt;SetFileName(argv[1]);<br>&nbsp;&nbsp;&nbsp; reader2-&gt;SetFileName(argv[2]);<br>&nbsp;&nbsp;&nbsp; reader3-&gt;SetFileName(argv[3]);<br><br>&nbsp;&nbsp;&nbsp; /* create ImageToVectorImageFilter, and set readers as the inputs */ <br>&nbsp;&nbsp;&nbsp; typedef itk::ImageToVectorImageFilter&lt;GrayImageType&gt; IToVImageFilterType;
<br>&nbsp;&nbsp;&nbsp; IToVImageFilterType::Pointer iToVFilter = IToVImageFilterType::New();<br>&nbsp;&nbsp;&nbsp; iToVFilter-&gt;SetNthInput(0, reader1-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; iToVFilter-&gt;SetNthInput(1, reader2-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; iToVFilter-&gt;SetNthInput(2, reader3-&gt;GetOutput());
<br><br>&nbsp;&nbsp;&nbsp; /* establish the filter&#39;s output type and create a pointer to the filter&#39;s results */<br>&nbsp;&nbsp;&nbsp; typedef itk::VectorImage&lt;GrayPixelType, ImageDimension &gt; VectorImageType;<br>&nbsp;&nbsp;&nbsp; VectorImageType::Pointer vectorImage = iToVFilter-&gt;GetOutput();
<br><br>&nbsp;&nbsp;&nbsp; /* use a filter that expects an Image&lt;Vector&lt;x,y&gt;, z&gt; as input */<br>&nbsp;&nbsp;&nbsp; typedef itk::Image&lt;unsigned int, ImageDimension&gt; KLMOutputImageType;<br>&nbsp;&nbsp;&nbsp; typedef itk::KLMRegionGrowImageFilter&lt; VectorImageType, KLMOutputImageType&gt; KLMFilterType;
<br>&nbsp;&nbsp;&nbsp; KLMFilterType::Pointer klmFilter = KLMFilterType::New();<br>&nbsp;&nbsp;&nbsp; klmFilter-&gt;SetMaximumNumberOfRegions(5);<br>&nbsp;&nbsp;&nbsp; klmFilter-&gt;SetMaximumLambda(10000000); //an arbitrarily large number<br>&nbsp;&nbsp;&nbsp; klmFilter-&gt;SetInput(vectorImage);
<br><br>&nbsp;&nbsp;&nbsp; klmFilter-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; /* rescale (if necessary) and output */<br>&nbsp;&nbsp;&nbsp; // ommitted, but essentially just:<br>&nbsp;&nbsp;&nbsp; // outputWriter-&gt;Setinput(klmfilter-&gt;GetLabelledOutput());<br>}&nbsp;&nbsp;  <br>