<div dir="ltr"><div><div><div>Thank you very much, Matt. <br></div>I would like to understand better how to do it in the correct way.. <br></div>Maybe you could help me more easily if I write some code as example of what I'm trying to do:<br>
<br></div>The main.cxx contains :<br><br> std::string inputFilename = argv[1];<br> std::string outputFilename = argv[2];<br><br> typedef itk::Image< int, 4 > InputImageType; //I've got an Input Image with all the four dimensions of int elements<br>
typedef itk::Image< double, 4 > OutputImageType; //my output image' fourth dimension should be of elements of type double<br> <br> typedef itk::ImageFileReader<InputImageType> ReaderType;<br><br> typedef itk::ImageFileWriter<OutputImageType> WriterType;<br>
<br> typedef itk::myFilter <InputImageType, OutputImageType> FilterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName(inputFilename);<br> <br> try<br> {<br> reader->Update();<br>
}<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excp << std::endl;<br> }<br><br> FilterType::Pointer myFilterPointer = FilterType::New();<br>
myFilterPointer->SetInput(reader->GetOutput());<br><br> try<br> {<br> myFilterPointer->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br>
std::cerr << excp << std::endl;<br> }<br><br><br> WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName(outputFilename);<br> writer->SetInput(myFilterPointer->GetOutput());<br>
try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excp << std::endl;<br>
}<br><div class="gmail_extra"><br>return EXIT_SUCCESS;<br>}<br><br><br></div><div class="gmail_extra">the myFilter.h header files contains:<br><br>namespace itk<br>{<br><br> template< class TInputImage, class TOutputImage><br>
class myFilter:<br> public ImageToImageFilter< TInputImage, TOutputImage ><br> {<br><br> public:<br> <br> /** Standard class typedefs. */<br> typedef myFilter Self;<br> typedef ImageToImageFilter < TInputImage, TOutputImage > Superclass;<br>
typedef SmartPointer< Self > Pointer;<br> typedef SmartPointer< const Self > ConstPointer;<br> <br> /** Method for creation through the object factory. */<br> itkNewMacro(Self);<br>
<br> /** Run-time type information (and related methods). */<br> itkTypeMacro(myFilter, ImageToImageFilter);<br> <br> <br><br> /* Typedef for images */<br> typedef TInputImage InputImageType;<br>
typedef TOutputImage OutputImageType; <br> typedef typename TInputImage::IndexType InputIndexType; //è lo stesso per l'immagine in input e quella in output?<br> typedef typename TOutputImage::IndexType OutputIndexType;<br>
typedef typename OutputImageType::Pointer OutputImagePointer;<br> typedef typename InputImageType::ConstPointer InputImageConstPointer;<br> typedef typename TInputImage::PixelType InputPixelType; // int<br>
typedef typename TOutputImage::PixelType OutputPixelType; //double<br> typedef typename TInputImage::SizeType InputImageSize; <br> typedef typename TOutputImage::SizeType OutputImageSize;<br>
<br> virtual void GenerateOutputInformation();<br><br>
<br> protected:<br> myFilter() {};<br> virtual ~myFilter(){} ; <br> <br> void PrintSelf(std::ostream & os, Indent indent) const;<br><br> void GenerateData(); //Method of the filter<br><br> private:<br>
myFilter(const Self &); //purposely not implemented<br> void operator=(const Self &); //purposely not implemented<br> //eventuali variabili:<br> double max_uptake; //picco<br> std::vector<int> x_t; //sarà il vettore contenente gli istanti di tempo (se ho 13 frame avrà 13 istanti di tempo, va da 0 a 13. <br>
std::vector<float> parameters; //Conterrà i parametri semiquantitativi <br> };<br>} //namespace ITK<br><br><br>#ifndef ITK_MANUAL_INSTANTIATION<br>#include "myFilter.hxx"<br>#endif<br><br><br><br></div>
<div class="gmail_extra">and in myFilter.hxx I have such a GenerateData method:<br><br>//GenerateData method <br></div></div>