#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mitkLog.h"
Go to the source code of this file.
Classes | |
struct | functionMapEntry |
Typedefs | |
typedef int(* | MainFuncPointer )(int, char *[]) |
Functions | |
int | mitkDemonsRegistrationTest (int, char *[]) |
int | mitkHistogramMatchingTest (int, char *[]) |
int | mitkSymmetricForcesDemonsRegistrationTest (int, char *[]) |
char * | lowercase (const char *string) |
int | main (int ac, char *av[]) |
Variables | |
functionMapEntry | cmakeGeneratedFunctionMapEntries [] |
typedef int(* MainFuncPointer)(int, char *[]) |
Definition at line 18 of file MitkDeformableRegistrationTestDriver.cpp.
char* lowercase | ( | const char * | string ) |
Definition at line 45 of file MitkDeformableRegistrationTestDriver.cpp.
{ char *new_string, *p; #ifdef __cplusplus new_string = static_cast<char *>(malloc(sizeof(char) * static_cast<size_t>(strlen(string) + 1))); #else new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1))); #endif if (!new_string) { return 0; } strcpy(new_string, string); p = new_string; while (*p != 0) { #ifdef __cplusplus *p = static_cast<char>(tolower(*p)); #else *p = (char)(tolower(*p)); #endif ++p; } return new_string; }
int main | ( | int | ac, |
char * | av[] | ||
) |
Definition at line 75 of file MitkDeformableRegistrationTestDriver.cpp.
References functionMapEntry::func, lowercase(), functionMapEntry::name, mitk::LoggingBackend::Register(), and mitk::LoggingBackend::Unregister().
{ int i, NumTests, testNum, partial_match; char *arg, *test_name; int count; int testToRun = -1; for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) { } NumTests = count; /* If no test name was given */ /* process command line with user function. */ if (ac < 2) { /* Ask for a test. */ printf("Available tests:\n"); for (i =0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); } printf("To run a test, enter the test number: "); fflush(stdout); testNum = 0; if( scanf("%d", &testNum) != 1 ) { printf("Couldn't parse that input as a number\n"); return -1; } if (testNum >= NumTests) { printf("%3d is an invalid test number.\n", testNum); return -1; } testToRun = testNum; ac--; av++; } partial_match = 0; arg = 0; /* If partial match is requested. */ if(testToRun == -1 && ac > 1) { partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; } if (partial_match && ac < 3) { printf("-R needs an additional parameter.\n"); return -1; } if(testToRun == -1) { arg = lowercase(av[1 + partial_match]); } for (i =0; i < NumTests && testToRun == -1; ++i) { test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); if (partial_match && strstr(test_name, arg) != NULL) { testToRun = i; ac -=2; av += 2; } else if (!partial_match && strcmp(test_name, arg) == 0) { testToRun = i; ac--; av++; } free(test_name); } if(arg) { free(arg); } if(testToRun != -1) { int result; mitk::LoggingBackend::Register(); ; result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); mitk::LoggingBackend::Unregister(); return result; } /* Nothing was run, display the test names. */ printf("Available tests:\n"); for (i =0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); } printf("Failed: %s is an invalid test name.\n", av[1]); return -1; }
int mitkDemonsRegistrationTest | ( | int | , |
char * | [] | ||
) |
Definition at line 21 of file mitkDemonsRegistrationTest.cpp.
References EXIT_SUCCESS, mitk::DemonsRegistration::New(), and mitk::Image::New().
{ //Create Image out of nowhere mitk::Image::Pointer image; mitk::PixelType pt(typeid(int)); unsigned int dim[]={100,100,20}; std::cout << "Creating image: "; image = mitk::Image::New(); //image->DebugOn(); image->Initialize(mitk::PixelType(typeid(int)), 3, dim); int *p = (int*)image->GetData(); int size = dim[0]*dim[1]*dim[2]; int i; for(i=0; i<size; ++i, ++p) *p=i; std::cout<<"[PASSED]"<<std::endl; //Create second Image out of nowhere mitk::Image::Pointer image2; mitk::PixelType pt2(typeid(int)); unsigned int dim2[]={100,100,20}; std::cout << "Creating image: "; image2 = mitk::Image::New(); //image->DebugOn(); image2->Initialize(mitk::PixelType(typeid(int)), 3, dim2); int *p2 = (int*)image2->GetData(); int size2 = dim2[0]*dim2[1]*dim2[2]; int i2; for(i2=0; i2<size2; ++i2, ++p2) *p2=i2; std::cout<<"[PASSED]"<<std::endl; std::cout << "Constructor: "; mitk::DemonsRegistration::Pointer demonsRegistration = mitk::DemonsRegistration::New(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Reference Image: "; demonsRegistration->SetReferenceImage(image); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Moving Image: "; demonsRegistration->SetInput(image2); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set number of iterations: "; demonsRegistration->SetNumberOfIterations(5); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set standard deviation: "; demonsRegistration->SetStandardDeviation(1.0); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set save deformation field: "; demonsRegistration->SetSaveDeformationField(false); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set deformation field file name: "; demonsRegistration->SetDeformationFieldFileName("TestField.mhd"); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set save result image: "; demonsRegistration->SetSaveResult(false); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set result image file name: "; demonsRegistration->SetResultFileName("TestResult.mhd"); std::cout<<"[PASSED]"<<std::endl; std::cout << "Perform registration: "; demonsRegistration->Update(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Get the result image: "; mitk::Image::Pointer resultImage = demonsRegistration->GetOutput(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Get the deformation field: "; itk::Image<class itk::Vector<float, 3>,3>::Pointer deformationField = demonsRegistration->GetDeformationField(); std::cout<<"[PASSED]"<<std::endl; return EXIT_SUCCESS; }
int mitkHistogramMatchingTest | ( | int | , |
char * | [] | ||
) |
Definition at line 21 of file mitkHistogramMatchingTest.cpp.
References EXIT_SUCCESS, mitk::HistogramMatching::New(), and mitk::Image::New().
{ //Create Image out of nowhere mitk::Image::Pointer image; mitk::PixelType pt(typeid(int)); unsigned int dim[]={100,100,20}; std::cout << "Creating image: "; image = mitk::Image::New(); //image->DebugOn(); image->Initialize(mitk::PixelType(typeid(int)), 3, dim); int *p = (int*)image->GetData(); int size = dim[0]*dim[1]*dim[2]; int i; for(i=0; i<size; ++i, ++p) *p=i; std::cout<<"[PASSED]"<<std::endl; //Create second Image out of nowhere mitk::Image::Pointer image2; mitk::PixelType pt2(typeid(int)); unsigned int dim2[]={100,100,20}; std::cout << "Creating image: "; image2 = mitk::Image::New(); //image->DebugOn(); image2->Initialize(mitk::PixelType(typeid(int)), 3, dim2); int *p2 = (int*)image2->GetData(); int size2 = dim2[0]*dim2[1]*dim2[2]; int i2; for(i2=0; i2<size2; ++i2, ++p2) *p2=i2; std::cout<<"[PASSED]"<<std::endl; std::cout << "Constructor: "; mitk::HistogramMatching::Pointer histogramMatching = mitk::HistogramMatching::New(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Reference Image: "; histogramMatching->SetReferenceImage(image); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Moving Image: "; histogramMatching->SetInput(image2); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set number of match points: "; histogramMatching->SetNumberOfMatchPoints(100); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set number of histogram levels: "; histogramMatching->SetNumberOfHistogramLevels(8); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set threshold at mean intensity: "; histogramMatching->SetThresholdAtMeanIntensity(true); std::cout<<"[PASSED]"<<std::endl; std::cout << "Perform histogram matching: "; histogramMatching->Update(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Get the result image: "; mitk::Image::Pointer histimage = histogramMatching->GetOutput(); std::cout<<"[PASSED]"<<std::endl; return EXIT_SUCCESS; }
int mitkSymmetricForcesDemonsRegistrationTest | ( | int | , |
char * | [] | ||
) |
Definition at line 21 of file mitkSymmetricForcesDemonsRegistrationTest.cpp.
References EXIT_SUCCESS, mitk::SymmetricForcesDemonsRegistration::New(), and mitk::Image::New().
{ //Create Image out of nowhere mitk::Image::Pointer image; mitk::PixelType pt(typeid(int)); unsigned int dim[]={100,100,20}; std::cout << "Creating image: "; image = mitk::Image::New(); //image->DebugOn(); image->Initialize(mitk::PixelType(typeid(int)), 3, dim); int *p = (int*)image->GetData(); int size = dim[0]*dim[1]*dim[2]; int i; for(i=0; i<size; ++i, ++p) *p=i; std::cout<<"[PASSED]"<<std::endl; //Create second Image out of nowhere mitk::Image::Pointer image2; mitk::PixelType pt2(typeid(int)); unsigned int dim2[]={100,100,20}; std::cout << "Creating image: "; image2 = mitk::Image::New(); //image->DebugOn(); image2->Initialize(mitk::PixelType(typeid(int)), 3, dim2); int *p2 = (int*)image2->GetData(); int size2 = dim2[0]*dim2[1]*dim2[2]; int i2; for(i2=0; i2<size2; ++i2, ++p2) *p2=i2; std::cout<<"[PASSED]"<<std::endl; std::cout << "Constructor: "; mitk::SymmetricForcesDemonsRegistration::Pointer symmetricForcesDemonsRegistration = mitk::SymmetricForcesDemonsRegistration::New(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Reference Image: "; symmetricForcesDemonsRegistration->SetReferenceImage(image); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set Moving Image: "; symmetricForcesDemonsRegistration->SetInput(image2); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set number of iterations: "; symmetricForcesDemonsRegistration->SetNumberOfIterations(5); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set standard deviation: "; symmetricForcesDemonsRegistration->SetStandardDeviation(1.0); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set save deformation field: "; symmetricForcesDemonsRegistration->SetSaveDeformationField(false); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set deformation field file name: "; symmetricForcesDemonsRegistration->SetDeformationFieldFileName("TestField.mhd"); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set save result image: "; symmetricForcesDemonsRegistration->SetSaveResult(false); std::cout<<"[PASSED]"<<std::endl; std::cout << "Set result image file name: "; symmetricForcesDemonsRegistration->SetResultFileName("TestResult.mhd"); std::cout<<"[PASSED]"<<std::endl; std::cout << "Perform registration: "; symmetricForcesDemonsRegistration->Update(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Get the result image: "; mitk::Image::Pointer resultImage = symmetricForcesDemonsRegistration->GetOutput(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Get the deformation field: "; itk::Image<class itk::Vector<float, 3>,3>::Pointer deformationField = symmetricForcesDemonsRegistration->GetDeformationField(); std::cout<<"[PASSED]"<<std::endl; return EXIT_SUCCESS; }
{ { "mitkDemonsRegistrationTest", mitkDemonsRegistrationTest }, { "mitkHistogramMatchingTest", mitkHistogramMatchingTest }, { "mitkSymmetricForcesDemonsRegistrationTest", mitkSymmetricForcesDemonsRegistrationTest }, {0,0} }
Definition at line 25 of file MitkDeformableRegistrationTestDriver.cpp.