• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

tests/itkreader/itkreader.cpp

Go to the documentation of this file.
00001 #include <QApplication>
00002 
00003 #include <itkImage.h>
00004 #include <itkImageFileReader.h>
00005 #include <itkInvertIntensityImageFilter.h>
00006 #include <itkSubtractImageFilter.h>
00007 
00008 #include "DGVImageVTK.h"
00009 #include "itkImageToVTKImageFilter.h"
00010 
00011 typedef float PixelType;
00012 typedef itk::Image<PixelType,2> ImageType;
00013 typedef itk::ImageFileReader< ImageType >  ReaderType;
00014 typedef itk::InvertIntensityImageFilter< ImageType >  InvertorType;
00015 typedef itk::SubtractImageFilter< ImageType >  SubtractType;
00016 typedef itk::ImageToVTKImageFilter< ImageType >  ConnectorType;
00017 
00018 int main(int argc, char *argv[])
00019 {
00020         QApplication app(argc,argv);
00021 
00022         if(argc == 3)
00023         {
00026             bool success = false;
00027             int bounds[6];
00028 
00030         ReaderType::Pointer reader = ReaderType::New();
00031             reader->SetFileName(argv[1]);
00032             reader->Update();
00033 
00035 //        InvertorType::Pointer invertor = InvertorType::New();
00036 //            invertor->SetInput( reader->GetOutput() );
00037 //            invertor->Update();
00038 //            invertor->Print(cerr);
00039 
00041             ConnectorType::Pointer connector = ConnectorType::New();
00042             connector->SetInput( reader->GetOutput() );
00043             connector->Update();
00044             connector->GetOutput()->GetExtent(bounds);
00045             cout << "Size: " << bounds[1] << "x" << bounds[3] << endl;
00046 
00048         DGVImageVTK *image1 = new DGVImageVTK;
00049             image1->alignImages(false); //Has no effect?
00050             image1->SetInput(connector->GetOutput());
00051             image1->generateImage();
00052             image1->show();
00053 
00056             ReaderType::Pointer reader2 = ReaderType::New();
00057             reader2->SetFileName(argv[2]);
00058             reader2->Update();
00059 
00061 //        InvertorType::Pointer invertor2 = InvertorType::New();
00062 //            invertor2->SetInput( reader2->GetOutput() );
00063 //            invertor2->Update();
00064 
00066         ConnectorType::Pointer connector2 = ConnectorType::New();
00067             connector2->SetInput( reader2->GetOutput() );
00068             connector2->Update();
00069             connector2->GetOutput()->GetExtent(bounds);
00070             cout << "Size: " << bounds[1] << "x" << bounds[3] << endl;
00071 
00073         DGVImageVTK *image2 = new DGVImageVTK;
00074             image2->alignImages(false); //Has no effect?
00075             image2->SetInput(connector2->GetOutput());
00076             image2->generateImage();
00077             image2->show();
00078 
00081         SubtractType::Pointer subtractor = SubtractType::New();
00082             subtractor->SetInput1( reader->GetOutput() );
00083             subtractor->SetInput2( reader2->GetOutput() );
00084             subtractor->Update();
00085 
00087         ConnectorType::Pointer connector3 = ConnectorType::New();
00088             connector3->SetInput( subtractor->GetOutput() );
00089             connector3->Update();
00090             connector3->GetOutput()->GetExtent(bounds);
00091             cout << "Size: " << bounds[1] << "x" << bounds[3] << endl;
00092 
00094         DGVImageVTK *image3 = new DGVImageVTK;
00095             image3->alignImages(false); //Has no effect?
00096             image3->SetInput(connector3->GetOutput());
00097             image3->generateImage();
00098             image3->show();
00099 
00100                 success = app.exec();
00101 
00102         //Smart pointer handles deletion
00103 
00104                 return EXIT_SUCCESS;
00105         }
00106         else
00107         {
00108                 cerr << "Error in Filename. Aborting." << endl;
00109                 return EXIT_FAILURE;
00110         }
00111 }
00112 

Generated on Wed Sep 8 2010 01:36:51 for DGV by  doxygen 1.7.1