22 #include <mapRegistrationAlgorithmInterface.h> 23 #include <mapAlgorithmEvents.h> 24 #include <mapAlgorithmWrapperEvent.h> 25 #include <mapExceptionObjectMacros.h> 26 #include <mapDeploymentDLLDirectoryBrowser.h> 27 #include <mapImageRegistrationAlgorithmInterface.h> 28 #include <mapPointSetRegistrationAlgorithmInterface.h> 29 #include <mapMaskedRegistrationAlgorithmInterface.h> 30 #include <mapConvert.h> 31 #include <mapDeploymentDLLAccess.h> 32 #include <mapRegistrationBase.h> 40 #include <QStringList> 41 #include <QCoreApplication> 46 int main(
int argc,
char* argv[])
64 std::map<std::string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
66 QFileInfo fi(argv[0]);
67 map::deployment::DLLDirectoryBrowser::Pointer browser = map::deployment::DLLDirectoryBrowser::New();
68 browser->addDLLSearchLocation(QDir::homePath().toStdString());
69 browser->addDLLSearchLocation(QDir::currentPath().toStdString());
70 browser->addDLLSearchLocation(fi.canonicalPath().toStdString());
72 auto dllList = browser->getLibraryInfos();
75 std::cout << std::endl <<
" --- Algorithm List --- " << std::endl;
76 for (
auto info : dllList)
78 std::cout <<
"Algorithm ID " <<
id <<
": " <<
info->getAlgorithmUID().getName() << std::endl;
81 std::cout << std::endl <<
" --- Interpolation List --- " << std::endl;
82 std::cout <<
"Interpolation ID 0: Linear Interpolation " << std::endl;
83 std::cout <<
"Interpolation ID 1: Nearest Neighbour" << std::endl;
84 std::cout <<
"Interpolation ID 2: BSpline 3D" << std::endl << std::endl;
88 if (parsedArgs.size()==0)
92 if ( parsedArgs.count(
"help") || parsedArgs.count(
"h"))
99 std::string movingFile =
us::any_cast<std::string>(parsedArgs[
"moving"]);
100 std::string fixedFile =
us::any_cast<std::string>(parsedArgs[
"fixed"]);
101 int selectedAlgorithm =
us::any_cast<
int>(parsedArgs[
"reader"]);
102 std::string outputPath =
us::any_cast<std::string>(parsedArgs[
"output"]);
104 if (parsedArgs.count(
"interpolation"))
106 switch (us::any_cast<int>(parsedArgs[
"interpolation"]))
126 auto dllInfo = dllList[selectedAlgorithm];
130 MITK_ERROR <<
"No valid algorithm is selected. Cannot load algorithm. ABORTING.";
134 ::map::deployment::DLLHandle::Pointer tempDLLHandle = ::map::deployment::openDeploymentDLL(
135 dllInfo->getLibraryFilePath());
136 ::map::algorithm::RegistrationAlgorithmBase::Pointer tempAlgorithm
137 = ::map::deployment::getRegistrationAlgorithm(tempDLLHandle);
139 if (tempAlgorithm.IsNull())
141 MITK_ERROR <<
"Error. Cannot load selected algorithm.";
146 helper.
SetData(movingImage, fixedImage);
154 fixedImage->GetGeometry()->Clone().GetPointer(),
map::core::RegistrationBase::Pointer GetRegistration() const
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
int main(int argc, char *argv[])
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false, mitkCommandLineParser::Channel channel=mitkCommandLineParser::Channel::None)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
static void info(const char *fmt,...)
void SetData(const mitk::BaseData *moving, const mitk::BaseData *target)
std::string helpText() const
void setCategory(std::string category)
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=nullptr, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
static void Save(const mitk::BaseData *data, const std::string &path, bool setPathProperty=false)
Save a mitk::BaseData instance.
void setTitle(std::string title)
void setDescription(std::string description)