Hi Itk-users,<br>
<br>After my message to Luis (please see below) I'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 " ImageToVectorImageFilter + ImageToListAdaptor " 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< TInputPixelType, NumberOfContrasts > 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< TInputPixelType, Dimension > TInputImageType;<br>
typedef itk::Image< TOutputPixelType, Dimension > TOutputImageType;<br><br><br> typedef itk::FixedArray< TInputPixelType, NumberOfContrasts > TMeasurementVectorType;<br> typedef itk::Image< TMeasurementVectorType, Dimension > TArrayImageType;<br>
<br> typedef itk::ScalarToArrayCastImageFilter< TInputImageType, TArrayImageType > CasterType;<br> CasterType::Pointer caster = CasterType::New();<br> caster->SetInput( 0, img );<br> caster->Update();<br>
<br> typedef itk::Statistics::ImageToListAdaptor< CasterType::OutputImageType > ImageToListAdaptorType;<br> ImageToListAdaptorType::Pointer adaptor = ImageToListAdaptorType::New();<br> adaptor->SetImage( caster->GetOutput() );<br>
<br> ///<br> /// Create the GMM<br> ///<br> TGMM< TArrayImageType, TOutputImageType > gmm;<br> gmm.SetInputArrayImage( caster->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 "io.h"<br>
#include "itkImageToVectorImageFilter.<div id=":7d" class="ii gt">h"<br>
#include "itkScalarToArrayCastImageFilter.h"<br>
#include "itkImageToListAdaptor.h"<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< TInputPixelType, Dimension ><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< TInputImageType >(<br>
"test.mnc" );<br>
<br>
typedef itk::ImageToVectorImageFilter< TInputImageType ><br>
ImageToVectorImageFilterType;<br>
ImageToVectorImageFilterType::Pointer vectorImage =<br>
ImageToVectorImageFilterType::New();<br>
vectorImage->SetNthInput( 0, img );<br>
vectorImage->Update();<br>
<br>
typedef itk::Statistics::ImageToListAdaptor<<br>
ImageToVectorImageFilterType::OutputImageType > ImageToListAdaptorType;<br>
ImageToListAdaptorType::Pointer adaptor = ImageToListAdaptorType::New();<br>
adaptor->SetImage( vectorImage->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<itk::VariableLengthVector<short int> >?:<br>
/usr/local/include/InsightToolkit/Numerics/Statistics/itkImageToListAdaptor.h:97:<br>
instantiated from<br>
?itk::Statistics::ImageToListAdaptor<itk::VectorImage<short int, 3u>,<br>
itk::VariableLengthVector<short int> >?<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<short int>?<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&<br>
itk::Statistics::ImageToListAdaptor<TImage,<br>
TMeasurementVector>::GetMeasurementVector(const typename<br>
TImage::PixelContainer::ElementIdentifier&) const [with TImage =<br>
itk::VectorImage<short int, 3u>, TMeasurementVector =<br>
itk::VariableLengthVector<short int>]?:<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>