[ITK-users] [ITK] Overload GenerateOutputInformation

Matt McCormick matt.mccormick at kitware.com
Wed May 7 00:14:24 EDT 2014


Hi Gianna,

Thanks for sharing the code.  Since the .hxx was missing, perhaps the
files can be uploaded to a Gist [1]. This will allow others on the
list to easily download them and try them out.

Thanks,
Matt

[1] https://gist.github.com/

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


More information about the Insight-users mailing list