diff --git a/Modules/BasicImageProcessing/CMakeLists.txt b/Modules/BasicImageProcessing/CMakeLists.txt new file mode 100644 index 0000000000..2f337313f9 --- /dev/null +++ b/Modules/BasicImageProcessing/CMakeLists.txt @@ -0,0 +1,8 @@ +MITK_CREATE_MODULE( + DEPENDS MitkCore + PACKAGE_DEPENDS + PUBLIC + PRIVATE ITK|ITKIOImageBase+ITKIOGDCM +) + +add_subdirectory(MiniApps) diff --git a/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt b/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt new file mode 100644 index 0000000000..e107b85391 --- /dev/null +++ b/Modules/BasicImageProcessing/MiniApps/CMakeLists.txt @@ -0,0 +1,88 @@ +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 + ) + + 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/FileConverter.cpp b/Modules/BasicImageProcessing/MiniApps/FileConverter.cpp new file mode 100644 index 0000000000..c349243f93 --- /dev/null +++ b/Modules/BasicImageProcessing/MiniApps/FileConverter.cpp @@ -0,0 +1,116 @@ +/*=================================================================== + +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 + +#include "mitkPreferenceListReaderOptionsFunctor.h" + + +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("reader", "r", mitkCommandLineParser::String, "Reader Name", "Reader Name", us::Any()); + parser.addArgument("list-readers", "lr", mitkCommandLineParser::Bool, "Reader Name", "Reader Name", us::Any()); + + + 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"]); + + mitk::PreferenceListReaderOptionsFunctor::ListType preference = {}; + if (parsedArgs.count("reader")) + { + preference.push_back(us::any_cast(parsedArgs["reader"])); + } + + if (parsedArgs.count("list-readers")) + { + mitk::IOUtil::LoadInfo loadInfo(inputFilename); + auto readers = loadInfo.m_ReaderSelector.Get(); + + std::string errMsg; + if (readers.empty()) + { + if (!itksys::SystemTools::FileExists(loadInfo.m_Path.c_str())) + { + errMsg += "File '" + loadInfo.m_Path + "' does not exist\n"; + } + else + { + errMsg += "No reader available for '" + loadInfo.m_Path + "'\n"; + } + MITK_ERROR << errMsg; + return 0; + } + + std::cout << "Available Readers: "< 0) + { + writeName = path + "/" + filename + "_" + std::to_string(count) + extension; + } + mitk::IOUtil::Save(node, writeName); + ++count; + } + + return EXIT_SUCCESS; +} diff --git a/Modules/BasicImageProcessing/MiniApps/ImageTypeConverter.cpp b/Modules/BasicImageProcessing/MiniApps/ImageTypeConverter.cpp new file mode 100644 index 0000000000..d576a303bd --- /dev/null +++ b/Modules/BasicImageProcessing/MiniApps/ImageTypeConverter.cpp @@ -0,0 +1,131 @@ +/*=================================================================== + +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 "mitkCommandLineParser.h" +#include "mitkIOUtil.h" +#include +#include + +#define CONVERT_IMAGE(TYPE, DIM) \ + MITK_INFO << "Data Type for Conversion: "<< typeid(TYPE).name(); \ + itk::Image::Pointer itkImage = itk::Image::New(); \ + mitk::CastToItkImage(image, itkImage); \ + mitk::CastToMitkImage(itkImage, outputImage) + +#define CONVERT_IMAGE_TYPE(TYPE) \ + unsigned int dimension = image->GetDimension(); \ + MITK_INFO >> "Image Dimension is: " << dimension; \ + switch (dimension) { \ + case 1 : CONVERT_IMAGE( TYPE , 1); \ + break; \ + case 2 : CONVERT_IMAGE( TYPE , 2); \ + break; \ + case 3 : CONVERT_IMAGE( TYPE , 3); \ + break; \ + case 4 : CONVERT_IMAGE( TYPE , 4); \ + break; \ + case 5 : CONVERT_IMAGE( TYPE , 5); \ + break; \ + case 6 : CONVERT_IMAGE( TYPE , 6); \ + break; \ + default: MITK_INFO << "This tool doesn't support a dimension of "< 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 inputName = us::any_cast(parsedArgs["input"]); + std::string outputName = us::any_cast(parsedArgs["output"]); + std::string type = us::any_cast(parsedArgs["type"]); + + mitk::Image::Pointer image = mitk::IOUtil::Load(inputName); + mitk::Image::Pointer outputImage = mitk::Image::New(); + + if (type.compare("int") == 0) { + CONVERT_IMAGE_TYPE(int); + } + else if (type.compare("uint") == 0) + { + CONVERT_IMAGE_TYPE(unsigned int); + } + else if (type.compare("char") == 0) + { + CONVERT_IMAGE_TYPE(char); + } + else if (type.compare("uchar") == 0) + { + CONVERT_IMAGE_TYPE(unsigned char); + } + else if (type.compare("short") == 0) + { + CONVERT_IMAGE_TYPE(short); + } + else if (type.compare("ushort") == 0) + { + CONVERT_IMAGE_TYPE(unsigned short); + } + else if (type.compare("float") == 0) + { + CONVERT_IMAGE_TYPE(float); + } + else if (type.compare("double") == 0) + { + CONVERT_IMAGE_TYPE(double); + } + else if (type.compare("none") == 0) + { + MITK_INFO << " No conversion performed"; + outputImage = NULL; + } + else + { + CONVERT_IMAGE_TYPE(double); + } + + if (outputImage->IsNotNull()) + { + mitk::IOUtil::Save(outputImage, outputName); + } + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/Modules/BasicImageProcessing/files.cmake b/Modules/BasicImageProcessing/files.cmake new file mode 100644 index 0000000000..826b9b5658 --- /dev/null +++ b/Modules/BasicImageProcessing/files.cmake @@ -0,0 +1,10 @@ +file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") + +set(CPP_FILES + mitkEmptyClass.cpp + mitkArithmeticOperation.cpp +) + +set(RESOURCE_FILES + +) diff --git a/Modules/BasicImageProcessing/include/mitkArithmeticOperation.h b/Modules/BasicImageProcessing/include/mitkArithmeticOperation.h new file mode 100644 index 0000000000..7b75ebbd8a --- /dev/null +++ b/Modules/BasicImageProcessing/include/mitkArithmeticOperation.h @@ -0,0 +1,104 @@ +/*=================================================================== + +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. + +===================================================================*/ + +#ifndef mitkArithmeticOperation_h +#define mitkArithmeticOperation_h + +#include +#include + +namespace mitk +{ + /** \brief Executes a arithmetic operations on one or two images + * + * All parameters of the arithmetic operations must be specified during construction. + * The actual operation is executed when calling GetResult(). + */ + class MITKBASICIMAGEPROCESSING_EXPORT ArithmeticOperation { + public: + static Image::Pointer Add(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Subtract(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Multiply(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Divide(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble = true); + + static Image::Pointer Add(Image::Pointer & imageA, double value, bool outputAsDouble = true); + static Image::Pointer Subtract(Image::Pointer & imageA, double value, bool outputAsDouble = true); + static Image::Pointer Multiply(Image::Pointer & imageA, double value, bool outputAsDouble = true); + static Image::Pointer Divide(Image::Pointer & imageA, double value, bool outputAsDouble = true); + + static Image::Pointer Add(double value, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Subtract(double value, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Multiply(double value, Image::Pointer & imageB, bool outputAsDouble = true); + static Image::Pointer Divide(double value, Image::Pointer & imageB, bool outputAsDouble = true); + + static Image::Pointer Tan(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Atan(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Cos(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Acos(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Sin(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Asin(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Square(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Sqrt(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Abs(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Exp(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer ExpNeg(Image::Pointer & imageA, bool outputAsDouble = true); + static Image::Pointer Log10(Image::Pointer & imageA, bool outputAsDouble = true); + }; + + class MITKBASICIMAGEPROCESSING_EXPORT NonStaticArithmeticOperation { + public: + enum OperationsEnum + { + Add2, + Sub2, + Mult, + Div, + AddValue, + SubValue, + MultValue, + DivValue, + PowValue, + Tan, + ATan, + Cos, + ACos, + Sin, + ASin, + Square, + Sqrt, + Abs, + Exp, + ExpNeg, + Log10 + }; + + + void CallExecuteTwoImageFilter(mitk::Image::Pointer imageA, mitk::Image::Pointer imageB); + + template + void ExecuteTwoImageFilter(itk::Image* imageA, itk::Image* imageB); + + template + void ExecuteTwoImageFilterWithFunctor(Image1Type* imageA, Image2Type* imageB); + + mitk::Image::Pointer m_ResultImage; + OperationsEnum m_Algorithm; + bool m_GenerateDoubleOutput = false; + }; + + +} +#endif // mitkArithmeticOperation_h \ No newline at end of file diff --git a/Modules/BasicImageProcessing/src/mitkArithmeticOperation.cpp b/Modules/BasicImageProcessing/src/mitkArithmeticOperation.cpp new file mode 100644 index 0000000000..f43f73f6dd --- /dev/null +++ b/Modules/BasicImageProcessing/src/mitkArithmeticOperation.cpp @@ -0,0 +1,557 @@ +/*=================================================================== + +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 "mitkArithmeticOperation.h" + +#include +#include +#include + +#include +#include +#include "itkUnaryFunctorImageFilter.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace mitk +{ + namespace Functor + { + template< class TInput, class TOutput> + class AddValue + { + public: + AddValue() {}; + ~AddValue() {}; + bool operator!=(const AddValue &) const + { + return false; + } + bool operator==(const AddValue & other) const + { + return !(*this != other); + } + inline TOutput operator()(const TInput & A) const + { + return A + value; + } + + bool valueLeft = false; + double value = 0.0; + }; + template< class TInput, class TOutput> + class SubValue + { + public: + SubValue() {}; + ~SubValue() {}; + bool operator!=(const SubValue &) const + { + return false; + } + bool operator==(const SubValue & other) const + { + return !(*this != other); + } + inline TOutput operator()(const TInput & A) const + { + if (valueLeft) + return value - A; + else + return A - value; + } + + bool valueLeft = false; + double value = 0.0; + }; + template< class TInput, class TOutput> + class MultValue + { + public: + MultValue() {}; + ~MultValue() {}; + bool operator!=(const MultValue &) const + { + return false; + } + bool operator==(const MultValue & other) const + { + return !(*this != other); + } + inline TOutput operator()(const TInput & A) const + { + return A * value; + } + + bool valueLeft = false; + double value = 0.0; + }; + template< class TInput, class TOutput> + class DivValue + { + public: + DivValue() {}; + ~DivValue() {}; + bool operator!=(const DivValue &) const + { + return false; + } + bool operator==(const DivValue & other) const + { + return !(*this != other); + } + inline TOutput operator()(const TInput & A) const + { + if (valueLeft) + return value / A; + else + return A / value; + } + + bool valueLeft = false; + double value = 1.0; + }; + template< class TInput, class TOutput> + class PowValue + { + public: + PowValue() {}; + ~PowValue() {}; + bool operator!=(const PowValue &) const + { + return false; + } + bool operator==(const PowValue & other) const + { + return !(*this != other); + } + inline TOutput operator()(const TInput & A) const + { + if (valueLeft) + return std::pow(value, A); + else + return std::pow(A, value); + } + + bool valueLeft = false; + double value = 1.0; + }; + } +} + +template +static void ExecuteOneImageFilter(itk::Image* imageA, double value, bool returnDoubleImage, bool valueLeft, bool parameterFree, mitk::NonStaticArithmeticOperation::OperationsEnum algorithm, mitk::Image::Pointer & outputImage) +{ + typedef itk::Image ImageType; + typedef itk::Image DoubleOutputType; + + + switch (algorithm) { + case mitk::NonStaticArithmeticOperation::OperationsEnum::AddValue: + ExecuteOneImageFilterWithFunctor, + mitk::Functor::AddValue, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::SubValue: + ExecuteOneImageFilterWithFunctor, + mitk::Functor::SubValue, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::MultValue: + ExecuteOneImageFilterWithFunctor, + mitk::Functor::MultValue, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::DivValue: + ExecuteOneImageFilterWithFunctor, + mitk::Functor::DivValue, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::PowValue: + ExecuteOneImageFilterWithFunctor, + mitk::Functor::PowValue, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + + case mitk::NonStaticArithmeticOperation::OperationsEnum::Tan: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Tan, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::ATan: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Atan, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Cos: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Cos, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::ACos: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Acos, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Sin: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Sin, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::ASin: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Asin, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Square: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Square, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Sqrt: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Sqrt, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Abs: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Abs, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Exp: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Exp, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::ExpNeg: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::ExpNegative, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + case mitk::NonStaticArithmeticOperation::OperationsEnum::Log10: + ExecuteOneImageFilterWithFunctorNonParameter, + itk::Functor::Log10, + ImageType, DoubleOutputType>(imageA, value, valueLeft, returnDoubleImage, parameterFree, outputImage); + break; + } +} + +template +static void ExecuteOneImageFilterWithFunctor(ImageType* imageA, double value, bool returnDoubleImage, bool valueLeft, bool parameterFree, mitk::Image::Pointer & outputImage) +{ + typedef itk::UnaryFunctorImageFilter< ImageType, ImageType, DefaultFunctorType > DefaultFilterType; + typedef itk::UnaryFunctorImageFilter< ImageType, DoubleImageType, DoubleFunctorType > DoubleFilterType; + + if (returnDoubleImage) + { + typename DoubleFilterType::Pointer filter = DoubleFilterType::New(); + filter->SetInput(imageA); + filter->GetFunctor().valueLeft = valueLeft; + filter->GetFunctor().value = value; + filter->Update(); + CastToMitkImage(filter->GetOutput(), outputImage); + } + else + { + typename DefaultFilterType::Pointer filter = DefaultFilterType::New(); + filter->SetInput(imageA); + filter->GetFunctor().valueLeft = valueLeft; + filter->GetFunctor().value = value; + filter->Update(); + CastToMitkImage(filter->GetOutput(), outputImage); + } +} + +template +static void ExecuteOneImageFilterWithFunctorNonParameter(ImageType* imageA, double value, bool returnDoubleImage, bool valueLeft, bool parameterFree, mitk::Image::Pointer & outputImage) +{ + typedef itk::UnaryFunctorImageFilter< ImageType, ImageType, DefaultFunctorType > DefaultFilterType; + typedef itk::UnaryFunctorImageFilter< ImageType, DoubleImageType, DoubleFunctorType > DoubleFilterType; + + if (returnDoubleImage) + { + typename DoubleFilterType::Pointer filter = DoubleFilterType::New(); + filter->SetInput(imageA); + filter->Update(); + CastToMitkImage(filter->GetOutput(), outputImage); + } + else + { + typename DefaultFilterType::Pointer filter = DefaultFilterType::New(); + filter->SetInput(imageA); + filter->Update(); + CastToMitkImage(filter->GetOutput(), outputImage); + } +} + + +mitk::Image::Pointer mitk::ArithmeticOperation::Add(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble) +{ + NonStaticArithmeticOperation helper; + helper.m_Algorithm = NonStaticArithmeticOperation::OperationsEnum::Add2; + helper.CallExecuteTwoImageFilter(imageA, imageB); + return helper.m_ResultImage; +} + +mitk::Image::Pointer mitk::ArithmeticOperation::Subtract(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble) +{ + NonStaticArithmeticOperation helper; + helper.m_Algorithm = NonStaticArithmeticOperation::OperationsEnum::Sub2; + helper.CallExecuteTwoImageFilter(imageA, imageB); + return helper.m_ResultImage; +} + +mitk::Image::Pointer mitk::ArithmeticOperation::Multiply(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble) +{ + NonStaticArithmeticOperation helper; + helper.m_Algorithm = NonStaticArithmeticOperation::OperationsEnum::Mult; + helper.CallExecuteTwoImageFilter(imageA, imageB); + return helper.m_ResultImage; +} + +mitk::Image::Pointer mitk::ArithmeticOperation::Divide(Image::Pointer & imageA, Image::Pointer & imageB, bool outputAsDouble) +{ + NonStaticArithmeticOperation helper; + helper.m_Algorithm = NonStaticArithmeticOperation::OperationsEnum::Div; + helper.CallExecuteTwoImageFilter(imageA, imageB); + return helper.m_ResultImage; +} + +mitk::Image::Pointer mitk::ArithmeticOperation::Add(Image::Pointer & imageA, double value, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, false, false, NonStaticArithmeticOperation::OperationsEnum::AddValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Subtract(Image::Pointer & imageA, double value, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, false, false, NonStaticArithmeticOperation::OperationsEnum::SubValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Multiply(Image::Pointer & imageA, double value, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, false, false, NonStaticArithmeticOperation::OperationsEnum::MultValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Divide(Image::Pointer & imageA, double value, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, false, false, NonStaticArithmeticOperation::OperationsEnum::DivValue, resultImage)); + return resultImage; +} + +mitk::Image::Pointer mitk::ArithmeticOperation::Add(double value, Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, true, false, NonStaticArithmeticOperation::OperationsEnum::AddValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Subtract(double value, Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, true, false, NonStaticArithmeticOperation::OperationsEnum::SubValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Multiply(double value, Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, true, false, NonStaticArithmeticOperation::OperationsEnum::MultValue, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Divide(double value, Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (value, outputAsDouble, true, false, NonStaticArithmeticOperation::OperationsEnum::DivValue, resultImage)); + return resultImage; +} + + +mitk::Image::Pointer mitk::ArithmeticOperation::Tan(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Tan, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Atan(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::ATan, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Sin(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Sin, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Asin(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::ASin, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Cos(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Cos, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Acos(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::ACos, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Square(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Square, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Sqrt(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Sqrt, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Abs(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Abs, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Exp(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Exp, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::ExpNeg(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::ExpNeg, resultImage)); + return resultImage; +} +mitk::Image::Pointer mitk::ArithmeticOperation::Log10(Image::Pointer & imageA, bool outputAsDouble) +{ + mitk::Image::Pointer resultImage; + AccessByItk_n(imageA, ExecuteOneImageFilter, (0.0, outputAsDouble, true, true, NonStaticArithmeticOperation::OperationsEnum::Log10, resultImage)); + return resultImage; +} + + +void mitk::NonStaticArithmeticOperation::CallExecuteTwoImageFilter(mitk::Image::Pointer imageA, mitk::Image::Pointer imageB) +{ + if (imageA->GetDimension() != imageB->GetDimension()) + { + mitkThrow() << "Image have different dimensions. This is not supported by mitk::ArithmeticOperation"; + } + + switch (imageA->GetDimension()) + { + case 1: + AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 1); + break; + case 2: + AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 2); + break; + case 3: + AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 3); + break; + case 4: + AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 4); + break; + default: + mitkThrow() << "Image Dimension of "<GetDimension() << " is not supported"; + break; + } +} + + +template +void mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter(itk::Image* imageA, itk::Image* imageB) +{ + typedef itk::Image Image1Type; + typedef itk::Image Image2Type; + typedef itk::Image DoubleOutputType; + + + switch (m_Algorithm) { + case OperationsEnum::Add2: + ExecuteTwoImageFilterWithFunctor, + itk::Functor::Add2, + Image1Type, Image2Type, DoubleOutputType>(imageA, imageB); + break; + + case OperationsEnum::Sub2: + ExecuteTwoImageFilterWithFunctor, + itk::Functor::Add2, + Image1Type, Image2Type, DoubleOutputType>(imageA, imageB); + break; + + case OperationsEnum::Mult: + ExecuteTwoImageFilterWithFunctor, + itk::Functor::Add2, + Image1Type, Image2Type, DoubleOutputType>(imageA, imageB); + break; + + case OperationsEnum::Div: + ExecuteTwoImageFilterWithFunctor, + itk::Functor::Add2, + Image1Type, Image2Type, DoubleOutputType>(imageA, imageB); + break; + } +} + +template +void mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilterWithFunctor(Image1Type* imageA, Image2Type* imageB) +{ + typedef itk::BinaryFunctorImageFilter< Image1Type, Image2Type, Image1Type,DefaultFunctorType > DefaultFilterType; + typedef itk::BinaryFunctorImageFilter< Image1Type, Image2Type, DoubleImageType, DoubleFunctorType > DoubleFilterType; + + if (m_GenerateDoubleOutput) + { + typename DoubleFilterType::Pointer filter = DoubleFilterType::New(); + filter->SetInput1(imageA); + filter->SetInput2(imageB); + filter->Update(); + CastToMitkImage(filter->GetOutput(), m_ResultImage); + } + else + { + typename DefaultFilterType::Pointer filter = DefaultFilterType::New(); + filter->SetInput1(imageA); + filter->SetInput2(imageB); + filter->Update(); + CastToMitkImage(filter->GetOutput(), m_ResultImage); + } +} \ No newline at end of file diff --git a/Modules/Classification/CLMiniApps/CLImageConverter.cpp b/Modules/Classification/CLMiniApps/CLImageConverter.cpp deleted file mode 100644 index de2ab03538..0000000000 --- a/Modules/Classification/CLMiniApps/CLImageConverter.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*=================================================================== - -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 "mitkCommandLineParser.h" -#include "mitkIOUtil.h" - -int main(int argc, char* argv[]) -{ - mitkCommandLineParser parser; - - parser.setTitle("Dicom Loader"); - parser.setCategory("Preprocessing Tools"); - 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::InputDirectory, "Input file:", "Input file",us::Any(),false); - parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output file",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 inputName = us::any_cast(parsedArgs["input"]); - std::string outputName = us::any_cast(parsedArgs["output"]); - - mitk::Image::Pointer image = mitk::IOUtil::Load(inputName); - mitk::IOUtil::Save(image, outputName); - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/Modules/Classification/CLMiniApps/CLImageTypeConverter.cpp b/Modules/Classification/CLMiniApps/CLImageTypeConverter.cpp deleted file mode 100644 index aeeaf8325a..0000000000 --- a/Modules/Classification/CLMiniApps/CLImageTypeConverter.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*=================================================================== - -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 "mitkCommandLineParser.h" -#include "mitkIOUtil.h" -#include -#include - -#define CONVERT_IMAGE(TYPE, DIM) itk::Image::Pointer itkImage = itk::Image::New(); \ - MITK_INFO << "Data Type for Conversion: "<< typeid(TYPE).name(); \ - mitk::CastToItkImage(image, itkImage); \ - mitk::CastToMitkImage(itkImage, outputImage) - -int main(int argc, char* argv[]) -{ - mitkCommandLineParser parser; - - parser.setTitle("Image Type Converter"); - parser.setCategory("Preprocessing Tools"); - 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::InputDirectory, "Input file:", "Input file",us::Any(),false); - parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output file:", "Output file", us::Any(), false); - parser.addArgument("type", "t", mitkCommandLineParser::OutputFile, "Type definition:", "Define Scalar data type: int, uint, short, ushort, char, uchar, float, double", 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 inputName = us::any_cast(parsedArgs["input"]); - std::string outputName = us::any_cast(parsedArgs["output"]); - std::string type = us::any_cast(parsedArgs["type"]); - - mitk::Image::Pointer image = mitk::IOUtil::Load(inputName); - mitk::Image::Pointer outputImage = mitk::Image::New(); - - if (type.compare("int") == 0) - { - CONVERT_IMAGE(int, 3); - } - else if (type.compare("uint") == 0) - { - CONVERT_IMAGE(unsigned int, 3); - } - else if (type.compare("char") == 0) - { - CONVERT_IMAGE(char, 3); - } - else if (type.compare("uchar") == 0) - { - CONVERT_IMAGE(unsigned char, 3); - } - else if (type.compare("short") == 0) - { - CONVERT_IMAGE(short, 3); - } - else if (type.compare("ushort") == 0) - { - CONVERT_IMAGE(unsigned short, 3); - } - else if (type.compare("float") == 0) - { - CONVERT_IMAGE(float, 3); - } - else if (type.compare("double") == 0) - { - CONVERT_IMAGE(double, 3); - } - else if (type.compare("none") == 0) - { - MITK_INFO << " No conversion performed"; - outputImage = image; - } - else - { - CONVERT_IMAGE(double, 3); - } - - - mitk::IOUtil::Save(outputImage, outputName); - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/Modules/Classification/CLMiniApps/CMakeLists.txt b/Modules/Classification/CLMiniApps/CMakeLists.txt index ab24948280..0bb6f5e560 100644 --- a/Modules/Classification/CLMiniApps/CMakeLists.txt +++ b/Modules/Classification/CLMiniApps/CMakeLists.txt @@ -1,143 +1,122 @@ option(BUILD_ClassificationMiniApps "Build commandline tools for classification" OFF) if(BUILD_ClassificationMiniApps 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( classificationminiapps RandomForestTraining^^MitkCLVigraRandomForest NativeHeadCTSegmentation^^MitkCLVigraRandomForest ManualSegmentationEvaluation^^MitkCLVigraRandomForest CLScreenshot^^MitkCore_MitkQtWidgetsExt_MitkCLUtilities CLDicom2Nrrd^^MitkCore - CLImageTypeConverter^^MitkCore CLResampleImageToReference^^MitkCore CLGlobalImageFeatures^^MitkCLUtilities_MitkQtWidgetsExt CLMRNormalization^^MitkCLUtilities_MitkCLMRUtilities CLStaple^^MitkCLUtilities CLVoxelFeatures^^MitkCLUtilities CLPolyToNrrd^^ CLPlanarFigureToNrrd^^MitkCore_MitkSegmentation_MitkMultilabel CLSimpleVoxelClassification^^MitkDataCollection_MitkCLVigraRandomForest CLVoxelClassification^^MitkDataCollection_MitkCLImportanceWeighting_MitkCLVigraRandomForest CLBrainMask^^MitkCLUtilities XRaxSimulationFromCT^^MitkCLUtilities CLRandomSampling^^MitkCore_MitkCLUtilities CLRemoveEmptyVoxels^^MitkCore CLN4^^MitkCore CLSkullMask^^MitkCore CLPointSetToSegmentation^^ CLMultiForestPrediction^^MitkDataCollection_MitkCLVigraRandomForest CLNrrdToPoly^^MitkCore CL2Dto3DImage^^MitkCore CLWeighting^^MitkCore_MitkCLImportanceWeighting_MitkCLUtilities CLOverlayRoiCenterOfMass^^MitkCore_MitkCLUtilities_MitkQtWidgetsExt CLLungSegmentation^^MitkCore_MitkSegmentation_MitkMultilabel # RandomForestPrediction^^MitkCLVigraRandomForest ) foreach(classificationminiapps ${classificationminiapps}) # extract mini app name and dependencies string(REPLACE "^^" "\\;" miniapp_info ${classificationminiapps}) 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 MitkCLCore MitkCommandLine ${dependencies_list} PACKAGE_DEPENDS ITK Qt5|Core Vigra 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() # This mini app does not depend on mitkDiffusionImaging at all mitk_create_executable(CLMatchPointReg DEPENDS MitkCore MitkCLUtilities MitkMatchPointRegistration MitkCommandLine MitkMatchPointRegistrationUI PACKAGE_DEPENDS ITK Qt5|Core Vigra MatchPoint CPP_FILES CLMatchPointReg.cpp ) - #mitk_create_executable(CLGlobalImageFeatures - # DEPENDS MitkCore MitkCLUtilities - # CPP_FILES CLGlobalImageFeatures.cpp mitkCommandLineParser.cpp - #) - #mitk_create_executable(CLBrainMask - # DEPENDS MitkCore MitkCLUtilities - # CPP_FILES CLBrainMask.cpp mitkCommandLineParser.cpp - #) - #mitk_create_executable(CLImageConverter - # DEPENDS MitkCore - # CPP_FILES CLImageConverter.cpp mitkCommandLineParser.cpp - #) - #mitk_create_executable(CLSurWeighting - # DEPENDS MitkCore MitkCLUtilities MitkDataCollection #MitkCLImportanceWeighting - # CPP_FILES CLSurWeighting.cpp mitkCommandLineParser.cpp - #) - #mitk_create_executable(CLImageCropper - # DEPENDS MitkCore MitkCLUtilities MitkAlgorithmsExt - # CPP_FILES CLImageCropper.cpp mitkCommandLineParser.cpp - #) # 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/ModuleList.cmake b/Modules/ModuleList.cmake index 8ac0be92e5..89c06dd6e0 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,77 +1,78 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(MITK_MODULES Core CommandLine AppUtil RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation QtWidgets QtWidgetsExt Chart SegmentationUI MatchPointRegistration MatchPointRegistrationUI Classification GPGPU OpenIGTLink IGTBase IGT CameraCalibration OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI PhotoacousticsHardware PhotoacousticsAlgorithms PhotoacousticsLib US USUI DicomUI Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware DiffusionImaging TumorInvasionAnalysis BoundingShape RenderWindowManager RenderWindowManagerUI CEST + BasicImageProcessing ) if(MITK_ENABLE_PIC_READER) list(APPEND MITK_MODULES IpPicSupportIO) endif()