Okay, solved it, or at least worked around it. As far as I can tell, ImageToVectorImageFilter is simply not useful for doing further vector-based processing on the image. Instead, use<br><br>ScalarToArrayCastImageFilter<br>
<br>noting that a Vector is a subclass of FixedArray.<br><br>(ITK Software Guide mentions this filter on Pg 610 and 693).<br><br>It was the name of the filter that gave me so much trouble -- it doesn't have any of the naming conventions I would have expected, whereas ImageToVectorImageFilter was named pretty much exactly as expected. In addition, none of the examples I've found ever use it for converting to a vector of dimension greater than 1. It's great that it exists though.
<br><br>Cheers,<br> - Dan<br><br><div><span class="gmail_quote">On 6/21/07, <b class="gmail_sendername">Dan Homerick</b> <<a href="mailto:danhomerick@gmail.com">danhomerick@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
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>
</blockquote></div><br>