diff --git a/Documentation/Doxygen/2-UserManual/MiniApps.dox b/Documentation/Doxygen/2-UserManual/MiniApps.dox
index eab8f29951..40a3835f29 100644
--- a/Documentation/Doxygen/2-UserManual/MiniApps.dox
+++ b/Documentation/Doxygen/2-UserManual/MiniApps.dox
@@ -1,59 +1,61 @@
/**
\page MiniAppExplainPage MITK MiniApps
\section MiniAppExplainPageDescription What are MiniApps
MiniApps are small command line tools. Generally the purpose of each of these tools is designed to fulfill one simple task,
e.g. resample an image or extract image statistics of a given region of interest (ROI).
They are intended to provide command line access to a variety of features of MITK, thus facilitating batched processing of data.
\section MiniAppExplainPageUsage Usage
Each MiniApp should provide information about its usage. If it is called without parameters it will output help information about expected inputs, outputs and parameters.
Below you can see the help output of the MitkGibbsTracking MiniApp:
\code
$./MitkGibbsTracking
-i, --input, input image (tensor, ODF or FSL/MRTrix SH-coefficient image)
-p, --parameters, parameter file (.gtp)
-m, --mask, binary mask image (optional)
-s, --shConvention, sh coefficient convention (FSL, MRtrix) (optional), (default: FSL)
-o, --outFile, output fiber bundle (.fib)
-f, --noFlip, do not flip input image to match MITK coordinate convention (optional)
\endcode
\section MiniAppExplainPageWorkbenchIntegration Integrating a command line tool into MITK Workbench
The executable file has be to be announced in MITK Workbench. This can be done in Preferences window:
Click 'Window' -> 'Preferences', and select 'Command Line Modules'. You can add directories containing executable files or you can select single executable files.
Click 'OK' button.
The configured command line tools are now available via the drop-down box of the Command Line Modules tab.
\warning The build configuration of your MiniApp should match the build configuration of your MITK application. This is especially relevant for developers. Combining a Release application and Debug MiniApp or vice versa might not work.
\section MiniAppExplainPageAvailableList Available MiniApps
\li \subpage DiffusionMiniApps
+\li \subpage mitkBasicImageProcessingMiniAppsPortalPage
+\li \subpage mitkClassificationMiniAppsPortalPage
\section MiniAppExplainPageTechnicalInformation Technical Information
MiniApps follow the Slicer Execution Model in describing themselves via xml:
\code
$./GibbsTracking --xml
Fiber Tracking and Processing Methods
Gibbs Tracking
MBI
...
\endcode
\note Full conformity is still a work in progress.
*/
diff --git a/Modules/BasicImageProcessing/CMakeLists.txt b/Modules/BasicImageProcessing/CMakeLists.txt
index 2f337313f9..6302c23500 100644
--- a/Modules/BasicImageProcessing/CMakeLists.txt
+++ b/Modules/BasicImageProcessing/CMakeLists.txt
@@ -1,8 +1,8 @@
MITK_CREATE_MODULE(
- DEPENDS MitkCore
+ DEPENDS MitkCore MitkMatchPointRegistration MitkMatchPointRegistrationIO
PACKAGE_DEPENDS
- PUBLIC
- PRIVATE ITK|ITKIOImageBase+ITKIOGDCM
+ PUBLIC
+ PRIVATE ITK|ITKIOImageBase+ITKIOGDCM
)
add_subdirectory(MiniApps)
diff --git a/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt b/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt
index e107b85391..2df1db81db 100644
--- a/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt
+++ b/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt
@@ -1,88 +1,98 @@
option(BUILD_BasicImageProcessingMiniApps "Build commandline tools for Basic Image Processing" OFF)
if(BUILD_BasicImageProcessingMiniApps OR MITK_BUILD_ALL_APPS)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# list of miniapps
# if an app requires additional dependencies
# they are added after a "^^" and separated by "_"
set( basicImageProcessingMiniApps
FileConverter^^MitkCore
ImageTypeConverter^^MitkCore
+ SingleImageArithmetic^^MitkCore_MitkBasicImageProcessing
+ TwoImageArithmetic^^MitkCore_MitkBasicImageProcessing
+ ImageAndValueArithmetic^^MitkCore_MitkBasicImageProcessing
+ MaskRangeBasedFiltering^^MitkCore_MitkBasicImageProcessing
+ MaskOutlierFiltering^^MitkCore_MitkBasicImageProcessing
+ ResampleImage^^MitkCore_MitkBasicImageProcessing
+ ResampleMask^^MitkCore_MitkBasicImageProcessing
+ LaplacianOfGaussian^^MitkCore_MitkBasicImageProcessing
+ MultiResolutionPyramid^^MitkCore_MitkBasicImageProcessing
+ ForwardWavelet^^MitkCore_MitkBasicImageProcessing
)
foreach(basicImageProcessingMiniApp ${basicImageProcessingMiniApps})
# extract mini app name and dependencies
string(REPLACE "^^" "\\;" miniapp_info ${basicImageProcessingMiniApp})
set(miniapp_info_list ${miniapp_info})
list(GET miniapp_info_list 0 appname)
list(GET miniapp_info_list 1 raw_dependencies)
string(REPLACE "_" "\\;" dependencies "${raw_dependencies}")
set(dependencies_list ${dependencies})
mitk_create_executable(${appname}
DEPENDS MitkCore MitkCommandLine ${dependencies_list}
PACKAGE_DEPENDS ITK
CPP_FILES ${appname}.cpp
)
# CPP_FILES ${appname}.cpp mitkCommandLineParser.cpp
if(EXECUTABLE_IS_ENABLED)
# On Linux, create a shell script to start a relocatable application
if(UNIX AND NOT APPLE)
install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${EXECUTABLE_TARGET}.sh)
endif()
get_target_property(_is_bundle ${EXECUTABLE_TARGET} MACOSX_BUNDLE)
if(APPLE)
if(_is_bundle)
set(_target_locations ${EXECUTABLE_TARGET}.app)
set(${_target_locations}_qt_plugins_install_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS)
set(_bundle_dest_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS)
set(_qt_plugins_for_current_bundle ${EXECUTABLE_TARGET}.app/Contents/MacOS)
set(_qt_conf_install_dirs ${EXECUTABLE_TARGET}.app/Contents/Resources)
install(TARGETS ${EXECUTABLE_TARGET} BUNDLE DESTINATION . )
else()
if(NOT MACOSX_BUNDLE_NAMES)
set(_qt_conf_install_dirs bin)
set(_target_locations bin/${EXECUTABLE_TARGET})
set(${_target_locations}_qt_plugins_install_dir bin)
install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin)
else()
foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources)
set(_current_target_location ${bundle_name}.app/Contents/MacOS/${EXECUTABLE_TARGET})
list(APPEND _target_locations ${_current_target_location})
set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS)
message( " set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ")
install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/)
endforeach()
endif()
endif()
else()
set(_target_locations bin/${EXECUTABLE_TARGET}${CMAKE_EXECUTABLE_SUFFIX})
set(${_target_locations}_qt_plugins_install_dir bin)
set(_qt_conf_install_dirs bin)
install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin)
endif()
endif()
endforeach()
# On Linux, create a shell script to start a relocatable application
if(UNIX AND NOT APPLE)
install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${EXECUTABLE_TARGET}.sh)
endif()
if(EXECUTABLE_IS_ENABLED)
MITK_INSTALL_TARGETS(EXECUTABLES ${EXECUTABLE_TARGET})
endif()
endif()
diff --git a/Modules/BasicImageProcessing/MiniApps/ForwardWavelet.cpp b/Modules/BasicImageProcessing/MiniApps/ForwardWavelet.cpp
new file mode 100644
index 0000000000..4ff8e80fde
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/ForwardWavelet.cpp
@@ -0,0 +1,142 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Multi-Resolution Pyramid");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+ parser.addArgument("output-extension", "e", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("number-of-levels", "levels", mitkCommandLineParser::Int, "Numbers of pyramid levels", "Number of pyramid levels", us::Any(), false);
+ parser.addArgument("number-of-bands", "bands", mitkCommandLineParser::Int, "Numbers of pyramid levels", "Number of pyramid levels", us::Any(), false);
+
+ parser.addArgument("wavelet", "w", mitkCommandLineParser::Int, "0: Shannon, 1: Simocelli, 2: Vow, 3: Held", "0: Shannon, 1: Simocelli, 2: Vow, 3: Held", us::Any(), false);
+ parser.addArgument("border-condition", "border", mitkCommandLineParser::Int, "0: Constant, 1: Periodic, 2: Zero Flux Neumann", "0: Constant, 1: Periodic, 2: Zero Flux Neumann", us::Any(), false);
+
+
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+ std::string outputExtension = us::any_cast(parsedArgs["output-extension"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+ int levels = us::any_cast(parsedArgs["number-of-levels"]);
+ int bands = us::any_cast(parsedArgs["number-of-bands"]);
+
+ mitk::BorderCondition condition = mitk::BorderCondition::Constant;
+ mitk::WaveletType waveletType = mitk::WaveletType::Held;
+ switch (us::any_cast(parsedArgs["wavelet"]))
+ {
+ case 0:
+ waveletType = mitk::WaveletType::Shannon;
+ break;
+ case 1:
+ waveletType = mitk::WaveletType::Simoncelli;
+ break;
+ case 2:
+ waveletType = mitk::WaveletType::Vow;
+ break;
+ case 3:
+ waveletType = mitk::WaveletType::Held;
+ break;
+ default:
+ waveletType = mitk::WaveletType::Shannon;
+ break;
+ }
+ switch (us::any_cast(parsedArgs["border-condition"]))
+ {
+ case 0:
+ condition = mitk::BorderCondition::Constant;
+ break;
+ case 1:
+ condition = mitk::BorderCondition::Periodic;
+ break;
+ case 2:
+ condition = mitk::BorderCondition::ZeroFluxNeumann;
+ break;
+ default:
+ condition = mitk::BorderCondition::Constant;
+ break;
+ }
+
+ std::vector results = mitk::TransformationOperation::WaveletForward(image, levels, bands, condition, waveletType);
+ unsigned int level = 0;
+ for (auto image : results)
+ {
+ std::string name = outputFilename + us::Any(level).ToString() + outputExtension;
+ MITK_INFO << "Saving to " << name;
+ mitk::IOUtil::Save(image, name);
+ ++level;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/ImageAndValueArithmetic.cpp b/Modules/BasicImageProcessing/MiniApps/ImageAndValueArithmetic.cpp
new file mode 100644
index 0000000000..3383450993
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/ImageAndValueArithmetic.cpp
@@ -0,0 +1,148 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("File Converter");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--","-");
+ // Add command line argument names
+ parser.addArgument("help", "h",mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input file:", "Input File",us::Any(),false);
+ parser.addArgument("value", "v", mitkCommandLineParser::Float, "Input Value:", "Input Value", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output file", us::Any(), false);
+
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result as double", "Result as double image type", false, true);
+ parser.addArgument("image-right", "right", mitkCommandLineParser::Bool, "Image right (for example Value - Image)", "Image right (for example Value - Image)", false, true);
+
+ parser.addArgument("add", "add", mitkCommandLineParser::Bool, "Add Left Image and Right Image", "Add Left Image and Right Image", us::Any(false), true);
+ parser.addArgument("subtract", "sub", mitkCommandLineParser::Bool, "Subtract right image from left image", "Subtract right image from left image", us::Any(false), true);
+ parser.addArgument("multiply", "multi", mitkCommandLineParser::Bool, "Multiply Left Image and Right Image", "Multiply Left Image and Right Image", us::Any(false), true);
+ parser.addArgument("divide", "div", mitkCommandLineParser::Bool, "Divide Left Image by Right Image", "Divide Left Image by Right Image", us::Any(false), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size()==0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if ( parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data is not of type image";
+ return 0;
+ }
+
+ double value = us::any_cast(parsedArgs["value"]);
+ bool resultAsDouble = ConvertToBool(parsedArgs, "as-double");
+ MITK_INFO << "Output image as double: " << resultAsDouble;
+
+ mitk::Image::Pointer tmpImage = image->Clone();
+ if (ConvertToBool(parsedArgs, "image-right"))
+ {
+ if (ConvertToBool(parsedArgs, "add"))
+ {
+ MITK_INFO << " Start Doing Operation: ADD()";
+ tmpImage = mitk::ArithmeticOperation::Add(value, tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "subtract"))
+ {
+ MITK_INFO << " Start Doing Operation: SUB()";
+ tmpImage = mitk::ArithmeticOperation::Subtract(value, tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "multiply"))
+ {
+ MITK_INFO << " Start Doing Operation: MULT()";
+ tmpImage = mitk::ArithmeticOperation::Multiply(value, tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "divide"))
+ {
+ MITK_INFO << " Start Doing Operation: DIV()";
+ tmpImage = mitk::ArithmeticOperation::Divide(value, tmpImage, resultAsDouble);
+ }
+ }
+ else {
+ if (ConvertToBool(parsedArgs, "add"))
+ {
+ MITK_INFO << " Start Doing Operation: ADD()";
+ tmpImage = mitk::ArithmeticOperation::Add(tmpImage, value, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "subtract"))
+ {
+ MITK_INFO << " Start Doing Operation: SUB()";
+ tmpImage = mitk::ArithmeticOperation::Subtract(tmpImage, value, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "multiply"))
+ {
+ MITK_INFO << " Start Doing Operation: MULT()";
+ tmpImage = mitk::ArithmeticOperation::Multiply(tmpImage, value, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "divide"))
+ {
+ MITK_INFO << " Start Doing Operation: DIV()";
+ tmpImage = mitk::ArithmeticOperation::Divide(tmpImage, value, resultAsDouble);
+ }
+
+ }
+
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/LaplacianOfGaussian.cpp b/Modules/BasicImageProcessing/MiniApps/LaplacianOfGaussian.cpp
new file mode 100644
index 0000000000..adca327480
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/LaplacianOfGaussian.cpp
@@ -0,0 +1,95 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Laplacian of Gaussian");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("sigma", "s", mitkCommandLineParser::Float, "Sigma for Gaussian", "Sigma for Gaussian", us::Any(), false);
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result Image as Type Double", "Result Image as Type Double", us::Any(false), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+ double sigma = us::any_cast(parsedArgs["sigma"]);
+
+
+
+ bool asDouble = ConvertToBool(parsedArgs, "as-double");
+ mitk::Image::Pointer tmpImage = mitk::TransformationOperation::LaplacianOfGaussian(image, sigma, asDouble);
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/MaskOutlierFiltering.cpp b/Modules/BasicImageProcessing/MiniApps/MaskOutlierFiltering.cpp
new file mode 100644
index 0000000000..9a4322033f
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/MaskOutlierFiltering.cpp
@@ -0,0 +1,91 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Mask Outlier filtering");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--","-");
+ // Add command line argument names
+ parser.addArgument("help", "h",mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image",us::Any(),false);
+ parser.addArgument("mask", "m", mitkCommandLineParser::InputFile, "Input mask:", "Input Mask", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size()==0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if ( parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string maskFilename = us::any_cast(parsedArgs["mask"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+
+ auto maskNodes = mitk::IOUtil::Load(maskFilename);
+ if (maskNodes.size() == 0)
+ {
+ MITK_INFO << "No Mask Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer mask = dynamic_cast(maskNodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (mask) is not of type image";
+ return 0;
+ }
+
+ mitk::Image::Pointer tmpImage = mitk::MaskCleaningOperation::MaskOutlierFiltering(image, mask);
+
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/MaskRangeBasedFiltering.cpp b/Modules/BasicImageProcessing/MiniApps/MaskRangeBasedFiltering.cpp
new file mode 100644
index 0000000000..d9f6b8257c
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/MaskRangeBasedFiltering.cpp
@@ -0,0 +1,114 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Mask Outlier filtering");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("mask", "m", mitkCommandLineParser::InputFile, "Input mask:", "Input Mask", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("lower-limit", "lL", mitkCommandLineParser::Float, "Lower Limit", "Lower Limit", us::Any(), true);
+ parser.addArgument("upper-limit", "ul", mitkCommandLineParser::Float, "Upper Limit", "Upper Limit", us::Any(), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string maskFilename = us::any_cast(parsedArgs["mask"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+
+ auto maskNodes = mitk::IOUtil::Load(maskFilename);
+ if (maskNodes.size() == 0)
+ {
+ MITK_INFO << "No Mask Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer mask = dynamic_cast(maskNodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (mask) is not of type image";
+ return 0;
+ }
+
+ bool useUpperLimit = false;
+ bool useLowerLimit = false;
+ double lowerLimit = 0;
+ double upperLimit = 1;
+
+ if (parsedArgs.count("lower-limit"))
+ {
+ useLowerLimit = true;
+ double lowerLimit = us::any_cast(parsedArgs["lower-limit"]);
+ }
+ if (parsedArgs.count("upper-limit"))
+ {
+ useUpperLimit = true;
+ double upperLimit = us::any_cast(parsedArgs["upper-limit"]);
+ }
+
+ if (useLowerLimit || useUpperLimit)
+ {
+ mitk::Image::Pointer tmpImage = mitk::MaskCleaningOperation::RangeBasedMasking(image, mask, useLowerLimit, lowerLimit, useUpperLimit, upperLimit);
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+ } else
+ {
+ MITK_INFO << "No limit specified. Specify either lower or upper limit";
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/MultiResolutionPyramid.cpp b/Modules/BasicImageProcessing/MiniApps/MultiResolutionPyramid.cpp
new file mode 100644
index 0000000000..89d85c7ff5
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/MultiResolutionPyramid.cpp
@@ -0,0 +1,100 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Multi-Resolution Pyramid");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+ parser.addArgument("output-extension", "e", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("number-of-levels", "levels", mitkCommandLineParser::Int, "Numbers of pyramid levels", "Number of pyramid levels", us::Any(), false);
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result Image as Type Double", "Result Image as Type Double", us::Any(false), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+ std::string outputExtension = us::any_cast(parsedArgs["output-extension"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+ int levels = us::any_cast(parsedArgs["number-of-levels"]);
+ bool asDouble = ConvertToBool(parsedArgs, "as-double");
+
+ std::vector results = mitk::TransformationOperation::MultiResolution(image, levels, asDouble);
+ unsigned int level = 1;
+ for (auto image : results)
+ {
+ std::string name = outputFilename + us::Any(levels - level).ToString() + outputExtension;
+ mitk::IOUtil::Save(image, name);
+ ++level;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/ResampleImage.cpp b/Modules/BasicImageProcessing/MiniApps/ResampleImage.cpp
new file mode 100644
index 0000000000..463b1e2f63
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/ResampleImage.cpp
@@ -0,0 +1,164 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Mask Outlier filtering");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("spacing-x", "x", mitkCommandLineParser::Float, "Spacing in x direction", "Spacing in x direction", us::Any(), false);
+ parser.addArgument("spacing-y", "y", mitkCommandLineParser::Float, "Spacing in y direction", "Spacing in y direction", us::Any(), false);
+ parser.addArgument("spacing-z", "z", mitkCommandLineParser::Float, "Spacing in z direction", "Spacing in z direction", us::Any(), false);
+
+ parser.addArgument("mapping-type", "mapping", mitkCommandLineParser::Int, "0: Origin aligned, 1: Center aligned, 3: Same size", "0: Origin aligned, 1: Center aligned, 3: Same size", us::Any(), true);
+ parser.addArgument("interpolator-type", "interpolator", mitkCommandLineParser::Int, "0: Linear, 1: BSpline 3, 2: Nearest Neighbour, 3: WSinc Hamming, 4: WSinc Welch", "0: Linear, 1: BSpline 3, 2: Nearest Neighbour, 3: WSinc Hamming, 4: WSinc Welch", us::Any(), true);
+
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result Image as Type Double", "Result Image as Type Double", us::Any(false), true);
+ parser.addArgument("round", "round", mitkCommandLineParser::Bool, "Round output", "round output", us::Any(false), true);
+
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+ mitk::Vector3D spacing;
+ spacing[0] = us::any_cast(parsedArgs["spacing-x"]);
+ spacing[1] = us::any_cast(parsedArgs["spacing-y"]);
+ spacing[2] = us::any_cast(parsedArgs["spacing-z"]);
+
+ int interpolator = 0;
+ if (parsedArgs.count("interpolator-type"))
+ {
+ interpolator = us::any_cast(parsedArgs["interpolator-type"]);
+ }
+
+ mitk::ImageMappingInterpolator::Type interpolatorType;
+ switch (interpolator)
+ {
+ case 0:
+ interpolatorType = mitk::ImageMappingInterpolator::Linear;
+ break;
+
+ case 1:
+ interpolatorType = mitk::ImageMappingInterpolator::BSpline_3;
+ break;
+
+ case 2:
+ interpolatorType = mitk::ImageMappingInterpolator::NearestNeighbor;
+ break;
+
+ case 3:
+ interpolatorType = mitk::ImageMappingInterpolator::WSinc_Hamming;
+ break;
+
+ case 4:
+ interpolatorType = mitk::ImageMappingInterpolator::WSinc_Welch;
+ break;
+
+ default:
+ interpolatorType = mitk::ImageMappingInterpolator::Linear;
+ }
+
+ int position = 0;
+ if (parsedArgs.count("mapping-type"))
+ {
+ position = us::any_cast(parsedArgs["mapping-type"]);
+ }
+
+ mitk::GridInterpolationPositionType gridPosition;
+ switch (position)
+ {
+ case 0:
+ gridPosition = mitk::GridInterpolationPositionType::OriginAligned;
+ break;
+
+ case 1:
+ gridPosition = mitk::GridInterpolationPositionType::CenterAligned;
+ break;
+
+ case 2:
+ gridPosition = mitk::GridInterpolationPositionType::SameSize;
+ break;
+
+ default:
+ gridPosition = mitk::GridInterpolationPositionType::OriginAligned;
+ }
+
+ bool asDouble = ConvertToBool(parsedArgs, "as-double");
+ bool round = ConvertToBool(parsedArgs, "round");
+
+ mitk::Image::Pointer tmpImage = mitk::TransformationOperation::ResampleImage(image, spacing, interpolatorType, gridPosition, asDouble, round);
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/ResampleMask.cpp b/Modules/BasicImageProcessing/MiniApps/ResampleMask.cpp
new file mode 100644
index 0000000000..b344c613d0
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/ResampleMask.cpp
@@ -0,0 +1,157 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("Mask Outlier filtering");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--", "-");
+ // Add command line argument names
+ parser.addArgument("help", "h", mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("image", "i", mitkCommandLineParser::InputFile, "Input image:", "Input Image", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output Mask", us::Any(), false);
+
+ parser.addArgument("spacing-x", "x", mitkCommandLineParser::Float, "Spacing in x direction", "Spacing in x direction", us::Any(), false);
+ parser.addArgument("spacing-y", "y", mitkCommandLineParser::Float, "Spacing in y direction", "Spacing in y direction", us::Any(), false);
+ parser.addArgument("spacing-z", "z", mitkCommandLineParser::Float, "Spacing in z direction", "Spacing in z direction", us::Any(), false);
+
+ parser.addArgument("mapping-type", "mapping", mitkCommandLineParser::Int, "0: Origin aligned, 1: Center aligned, 3: Same size", "0: Origin aligned, 1: Center aligned, 3: Same size", us::Any(), true);
+ parser.addArgument("interpolator-type", "interpolator", mitkCommandLineParser::Int, "0: Linear, 1: BSpline 3, 2: Nearest Neighbour, 3: WSinc Hamming, 4: WSinc Welch", "0: Linear, 1: BSpline 3, 2: Nearest Neighbour, 3: WSinc Hamming, 4: WSinc Welch", us::Any(), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size() == 0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if (parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["image"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data (image) is not of type image";
+ return 0;
+ }
+
+ mitk::Vector3D spacing;
+ spacing[0] = us::any_cast(parsedArgs["spacing-x"]);
+ spacing[1] = us::any_cast(parsedArgs["spacing-y"]);
+ spacing[2] = us::any_cast(parsedArgs["spacing-z"]);
+
+ int interpolator = 0;
+ if (parsedArgs.count("interpolator-type"))
+ {
+ interpolator = us::any_cast(parsedArgs["interpolator-type"]);
+ }
+
+ mitk::ImageMappingInterpolator::Type interpolatorType;
+ switch (interpolator)
+ {
+ case 0:
+ interpolatorType = mitk::ImageMappingInterpolator::Linear;
+ break;
+
+ case 1:
+ interpolatorType = mitk::ImageMappingInterpolator::BSpline_3;
+ break;
+
+ case 2:
+ interpolatorType = mitk::ImageMappingInterpolator::NearestNeighbor;
+ break;
+
+ case 3:
+ interpolatorType = mitk::ImageMappingInterpolator::WSinc_Hamming;
+ break;
+
+ case 4:
+ interpolatorType = mitk::ImageMappingInterpolator::WSinc_Welch;
+ break;
+
+ default:
+ interpolatorType = mitk::ImageMappingInterpolator::Linear;
+ }
+
+ int position = 0;
+ if (parsedArgs.count("mapping-type"))
+ {
+ position = us::any_cast(parsedArgs["mapping-type"]);
+ }
+
+ mitk::GridInterpolationPositionType gridPosition;
+ switch (position)
+ {
+ case 0:
+ gridPosition = mitk::GridInterpolationPositionType::OriginAligned;
+ break;
+
+ case 1:
+ gridPosition = mitk::GridInterpolationPositionType::CenterAligned;
+ break;
+
+ case 2:
+ gridPosition = mitk::GridInterpolationPositionType::SameSize;
+ break;
+
+ default:
+ gridPosition = mitk::GridInterpolationPositionType::OriginAligned;
+ }
+
+ mitk::Image::Pointer tmpImage = mitk::TransformationOperation::ResampleMask(image, spacing, interpolatorType, gridPosition);
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/SingleImageArithmetic.cpp b/Modules/BasicImageProcessing/MiniApps/SingleImageArithmetic.cpp
new file mode 100644
index 0000000000..7becbd78a5
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/SingleImageArithmetic.cpp
@@ -0,0 +1,168 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("File Converter");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--","-");
+ // Add command line argument names
+ parser.addArgument("help", "h",mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("input", "i", mitkCommandLineParser::InputFile, "Input file:", "Input File",us::Any(),false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output file", us::Any(), false);
+
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result as double", "Result as double image type", false, true);
+
+ parser.addArgument("tan", "tan", mitkCommandLineParser::Bool, "Calculate tan operation", "Calculate tan operation", us::Any(false), true);
+ parser.addArgument("atan", "atan", mitkCommandLineParser::Bool, "Calculate atan operation", "Calculate atan operation", us::Any(false), true);
+ parser.addArgument("cos", "cos", mitkCommandLineParser::Bool, "Calculate cos operation", "Calculate cos operation", us::Any(false), true);
+ parser.addArgument("acos", "acos", mitkCommandLineParser::Bool, "Calculate acos operation", "Calculate acos operation", us::Any(false), true);
+ parser.addArgument("sin", "sin", mitkCommandLineParser::Bool, "Calculate sin operation", "Calculate sin operation", us::Any(false), true);
+ parser.addArgument("asin", "asin", mitkCommandLineParser::Bool, "Calculate asin operation", "Calculate asin operation", us::Any(false), true);
+ parser.addArgument("square", "square", mitkCommandLineParser::Bool, "Calculate square operation", "Calculate square operation", us::Any(false), true);
+ parser.addArgument("sqrt", "sqrt", mitkCommandLineParser::Bool, "Calculate sqrt operation", "Calculate sqrt operation", us::Any(false), true);
+ parser.addArgument("abs", "abs", mitkCommandLineParser::Bool, "Calculate abs operation", "Calculate abs operation", us::Any(false), true);
+ parser.addArgument("exp", "exp", mitkCommandLineParser::Bool, "Calculate exp operation", "Calculate exp operation", us::Any(false), true);
+ parser.addArgument("expneg", "expneg", mitkCommandLineParser::Bool, "Calculate expneg operation", "Calculate expneg operation", us::Any(false), true);
+ parser.addArgument("log10", "log10", mitkCommandLineParser::Bool, "Calculate log10 operation", "Calculate log10 operation", us::Any(false), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size()==0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if ( parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename = us::any_cast(parsedArgs["input"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes = mitk::IOUtil::Load(inputFilename);
+ if (nodes.size() == 0)
+ {
+ MITK_INFO << "No Image Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image = dynamic_cast(nodes[0].GetPointer());
+
+ if (image.IsNull())
+ {
+ MITK_INFO << "Loaded data is not of type image";
+ return 0;
+ }
+
+ bool resultAsDouble = ConvertToBool(parsedArgs, "as-double");
+ MITK_INFO << "Output image as double: " << resultAsDouble;
+
+ mitk::Image::Pointer tmpImage = image->Clone();
+
+ if (ConvertToBool(parsedArgs, "tan"))
+ {
+ MITK_INFO << " Start Doing Operation: TAN()";
+ tmpImage = mitk::ArithmeticOperation::Tan(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "atan"))
+ {
+ MITK_INFO << " Start Doing Operation: ATAN()";
+ tmpImage = mitk::ArithmeticOperation::Atan(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "cos"))
+ {
+ MITK_INFO << " Start Doing Operation: COS()";
+ tmpImage = mitk::ArithmeticOperation::Cos(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "acos"))
+ {
+ MITK_INFO << " Start Doing Operation: ACOS()";
+ tmpImage = mitk::ArithmeticOperation::Acos(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "sin"))
+ {
+ MITK_INFO << " Start Doing Operation: SIN()";
+ tmpImage = mitk::ArithmeticOperation::Sin(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "asin"))
+ {
+ MITK_INFO << " Start Doing Operation: ASIN()";
+ tmpImage = mitk::ArithmeticOperation::Asin(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "square"))
+ {
+ MITK_INFO << " Start Doing Operation: SQUARE()";
+ tmpImage = mitk::ArithmeticOperation::Square(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "sqrt"))
+ {
+ MITK_INFO << " Start Doing Operation: SQRT()";
+ tmpImage = mitk::ArithmeticOperation::Sqrt(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "abs"))
+ {
+ MITK_INFO << " Start Doing Operation: ABS()";
+ tmpImage = mitk::ArithmeticOperation::Abs(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "exp"))
+ {
+ MITK_INFO << " Start Doing Operation: EXP()";
+ tmpImage = mitk::ArithmeticOperation::Exp(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "expneg"))
+ {
+ MITK_INFO << " Start Doing Operation: EXPNEG()";
+ tmpImage = mitk::ArithmeticOperation::ExpNeg(tmpImage, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "log10"))
+ {
+ MITK_INFO << " Start Doing Operation: LOG10()";
+ tmpImage = mitk::ArithmeticOperation::Log10(tmpImage, resultAsDouble);
+ }
+
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/MiniApps/TwoImageArithmetic.cpp b/Modules/BasicImageProcessing/MiniApps/TwoImageArithmetic.cpp
new file mode 100644
index 0000000000..584ea4ab73
--- /dev/null
+++ b/Modules/BasicImageProcessing/MiniApps/TwoImageArithmetic.cpp
@@ -0,0 +1,134 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkProperties.h"
+
+#include "mitkCommandLineParser.h"
+#include "mitkIOUtil.h"
+
+#include
+
+static bool ConvertToBool(std::map &data, std::string name)
+{
+ if (!data.count(name))
+ {
+ return false;
+ }
+ try {
+ return us::any_cast(data[name]);
+ }
+ catch (us::BadAnyCastException &)
+ {
+ return false;
+ }
+}
+
+
+int main(int argc, char* argv[])
+{
+ mitkCommandLineParser parser;
+
+ parser.setTitle("File Converter");
+ parser.setCategory("Basic Image Processing");
+ parser.setDescription("");
+ parser.setContributor("MBI");
+
+ parser.setArgumentPrefix("--","-");
+ // Add command line argument names
+ parser.addArgument("help", "h",mitkCommandLineParser::Bool, "Help:", "Show this help text");
+ parser.addArgument("input-left", "i1", mitkCommandLineParser::InputFile, "Input file:", "Input File",us::Any(),false);
+ parser.addArgument("input-right", "i2", mitkCommandLineParser::InputFile, "Input file:", "Input File", us::Any(), false);
+ parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output file", us::Any(), false);
+
+ parser.addArgument("as-double", "double", mitkCommandLineParser::Bool, "Result as double", "Result as double image type", false, true);
+
+ parser.addArgument("add", "add", mitkCommandLineParser::Bool, "Add Left Image and Right Image", "Add Left Image and Right Image", us::Any(false), true);
+ parser.addArgument("subtract", "sub", mitkCommandLineParser::Bool, "Subtract right image from left image", "Subtract right image from left image", us::Any(false), true);
+ parser.addArgument("multiply", "multi", mitkCommandLineParser::Bool, "Multiply Left Image and Right Image", "Multiply Left Image and Right Image", us::Any(false), true);
+ parser.addArgument("divide", "div", mitkCommandLineParser::Bool, "Divide Left Image by Right Image", "Divide Left Image by Right Image", us::Any(false), true);
+
+ std::map parsedArgs = parser.parseArguments(argc, argv);
+
+ if (parsedArgs.size()==0)
+ return EXIT_FAILURE;
+
+ // Show a help message
+ if ( parsedArgs.count("help") || parsedArgs.count("h"))
+ {
+ std::cout << parser.helpText();
+ return EXIT_SUCCESS;
+ }
+
+ std::string inputFilename1 = us::any_cast(parsedArgs["input-left"]);
+ std::string inputFilename2 = us::any_cast(parsedArgs["input-right"]);
+ std::string outputFilename = us::any_cast(parsedArgs["output"]);
+
+ auto nodes1 = mitk::IOUtil::Load(inputFilename1);
+ auto nodes2 = mitk::IOUtil::Load(inputFilename2);
+ if (nodes1.size() == 0)
+ {
+ MITK_INFO << "No Image (left) Loaded";
+ return 0;
+ }
+ if (nodes2.size() == 0)
+ {
+ MITK_INFO << "No Image (right) Loaded";
+ return 0;
+ }
+ mitk::Image::Pointer image1 = dynamic_cast(nodes1[0].GetPointer());
+ mitk::Image::Pointer image2 = dynamic_cast(nodes2[0].GetPointer());
+
+ if (image1.IsNull())
+ {
+ MITK_INFO << "Loaded data (left) is not of type image";
+ return 0;
+ }
+ if (image2.IsNull())
+ {
+ MITK_INFO << "Loaded data (right) is not of type image";
+ return 0;
+ }
+
+ bool resultAsDouble = ConvertToBool(parsedArgs, "as-double");
+ MITK_INFO << "Output image as double: " << resultAsDouble;
+
+ mitk::Image::Pointer tmpImage = image1->Clone();
+
+ if (ConvertToBool(parsedArgs, "add"))
+ {
+ MITK_INFO << " Start Doing Operation: ADD()";
+ tmpImage = mitk::ArithmeticOperation::Add(tmpImage, image2, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "subtract"))
+ {
+ MITK_INFO << " Start Doing Operation: SUB()";
+ tmpImage = mitk::ArithmeticOperation::Subtract(tmpImage, image2, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "multiply"))
+ {
+ MITK_INFO << " Start Doing Operation: MULT()";
+ tmpImage = mitk::ArithmeticOperation::Multiply(tmpImage, image2, resultAsDouble);
+ }
+ if (ConvertToBool(parsedArgs, "divide"))
+ {
+ MITK_INFO << " Start Doing Operation: DIV()";
+ tmpImage = mitk::ArithmeticOperation::Divide(tmpImage, image2, resultAsDouble);
+ }
+
+ mitk::IOUtil::Save(tmpImage, outputFilename);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Modules/BasicImageProcessing/documentation/UserManual/mitkBasicImageProcessingMiniAppsPortalPage.dox b/Modules/BasicImageProcessing/documentation/UserManual/mitkBasicImageProcessingMiniAppsPortalPage.dox
new file mode 100644
index 0000000000..93627d40be
--- /dev/null
+++ b/Modules/BasicImageProcessing/documentation/UserManual/mitkBasicImageProcessingMiniAppsPortalPage.dox
@@ -0,0 +1,45 @@
+/**
+\page mitkBasicImageProcessingMiniAppsPortalPage MITK Basic Image Processing Mini Apps
+
+\tableofcontents
+
+The Basic Image Processing Mini Apps bundle the functionality that is commonly neeeded for the processing of medical images. As all other MiniApps, they follow the Slicer Execution Model in describing themselves via xml. You can simply obtain a description by calling the MiniApp without any parameter. If the MiniApp is calles with the option "--xml" a XML description of all possible parameter is added.
+
+\section bipmasec1 Description of Mini Apps
+
+\subsection bipmasub1 mitkFileConverter
+Allows to convert a file from one type to another file type, for example to convert an image, saved in the nifti format to an image saved in the .nrrd format.
+
+\subsection bipmasub2 mitkForwardWavelet
+Calculates the forward wavelet transformation of an image. The output will consist of multiple images, which will be saved in the format