Hello all,<br><br>I'm stumped, and I'm not exactly sure of what the core problem is. I'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'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'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'm trying to do it like this:<br><br>#include "itkImageFileReader.h"<br>#include "
itkImageToVectorImageFilter.h"<br>#include "itkKLMRegionGrowImageFilter.h"<br>#include "itkImageFileWriter.h"<br><br>int main( int argc, char ** argv )<br>{<br> if( argc < 5 )<br> {<br> std::cerr << "Usage: " << std::endl;
<br> std::cerr << argv[0] << " input1 input2 input3 output" << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> /* Establish input image types */<br> typedef unsigned char GrayPixelType;
<br> const unsigned int ImageDimension = 2;<br> typedef itk::Image< GrayPixelType, ImageDimension > GrayImageType;<br> typedef itk::ImageFileReader< GrayImageType > ReaderType;
<br><br> /* create 3 readers, one for each spectral band */<br> ReaderType::Pointer reader1 = ReaderType::New();<br> ReaderType::Pointer reader2 = ReaderType::New();<br> ReaderType::Pointer reader3 = ReaderType::New();
<br> <br> reader1->SetFileName(argv[1]);<br> reader2->SetFileName(argv[2]);<br> reader3->SetFileName(argv[3]);<br><br> /* create ImageToVectorImageFilter, and set readers as the inputs */ <br> typedef itk::ImageToVectorImageFilter<GrayImageType> IToVImageFilterType;
<br> IToVImageFilterType::Pointer iToVFilter = IToVImageFilterType::New();<br> iToVFilter->SetNthInput(0, reader1->GetOutput());<br> iToVFilter->SetNthInput(1, reader2->GetOutput());<br> iToVFilter->SetNthInput(2, reader3->GetOutput());
<br><br> /* establish the filter's output type and create a pointer to the filter's results */<br> typedef itk::VectorImage<GrayPixelType, ImageDimension > VectorImageType;<br> VectorImageType::Pointer vectorImage = iToVFilter->GetOutput();
<br><br> /* use a filter that expects an Image<Vector<x,y>, z> as input */<br> typedef itk::Image<unsigned int, ImageDimension> KLMOutputImageType;<br> typedef itk::KLMRegionGrowImageFilter< VectorImageType, KLMOutputImageType> KLMFilterType;
<br> KLMFilterType::Pointer klmFilter = KLMFilterType::New();<br> klmFilter->SetMaximumNumberOfRegions(5);<br> klmFilter->SetMaximumLambda(10000000); //an arbitrarily large number<br> klmFilter->SetInput(vectorImage);
<br><br> klmFilter->Update();<br><br> /* rescale (if necessary) and output */<br> // ommitted, but essentially just:<br> // outputWriter->Setinput(klmfilter->GetLabelledOutput());<br>} <br>