diff --git a/Modules/Classification/CLMiniApps/CLVoxelFeatures.cpp b/Modules/Classification/CLMiniApps/CLVoxelFeatures.cpp index 677bc2890a..55bd36b3c4 100644 --- a/Modules/Classification/CLMiniApps/CLVoxelFeatures.cpp +++ b/Modules/Classification/CLMiniApps/CLVoxelFeatures.cpp @@ -1,335 +1,335 @@ /*=================================================================== 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 mitkCLVoxeFeatures_cpp #define mitkCLVoxeFeatures_cpp #include "time.h" #include #include #include #include #include #include "mitkCommandLineParser.h" #include #include #include "itkDiscreteGaussianImageFilter.h" #include #include "itkHessianRecursiveGaussianImageFilter.h" #include "itkUnaryFunctorImageFilter.h" -#include #include "vnl/algo/vnl_symmetric_eigensystem.h" +#include #include static std::vector splitDouble(std::string str, char delimiter) { std::vector internal; std::stringstream ss(str); // Turn the string into a stream. std::string tok; double val; while (std::getline(ss, tok, delimiter)) { std::stringstream s2(tok); s2 >> val; internal.push_back(val); } return internal; } namespace Functor { template class MatrixFirstEigenvalue { public: MatrixFirstEigenvalue() {} virtual ~MatrixFirstEigenvalue() {} int order; inline TOutput operator ()(const TInput& input) { double a,b,c; if (input[0] < 0.01 && input[1] < 0.01 &&input[2] < 0.01 &&input[3] < 0.01 &&input[4] < 0.01 &&input[5] < 0.01) return 0; vnl_symmetric_eigensystem_compute_eigenvals(input[0], input[1],input[2],input[3],input[4],input[5],a,b,c); switch (order) { case 0: return a; case 1: return b; case 2: return c; default: return a; } } bool operator !=(const MatrixFirstEigenvalue) const { return false; } bool operator ==(const MatrixFirstEigenvalue& other) const { return !(*this != other); } }; } template void GaussianFilter(itk::Image* itkImage, double variance, mitk::Image::Pointer &output) { typedef itk::Image ImageType; typedef itk::DiscreteGaussianImageFilter< ImageType, ImageType > GaussFilterType; typename GaussFilterType::Pointer gaussianFilter = GaussFilterType::New(); gaussianFilter->SetInput( itkImage ); gaussianFilter->SetVariance(variance); gaussianFilter->Update(); mitk::CastToMitkImage(gaussianFilter->GetOutput(), output); } template void DifferenceOfGaussFilter(itk::Image* itkImage, double variance, mitk::Image::Pointer &output) { typedef itk::Image ImageType; typedef itk::DiscreteGaussianImageFilter< ImageType, ImageType > GaussFilterType; typedef itk::SubtractImageFilter SubFilterType; typename GaussFilterType::Pointer gaussianFilter1 = GaussFilterType::New(); gaussianFilter1->SetInput( itkImage ); gaussianFilter1->SetVariance(variance); gaussianFilter1->Update(); typename GaussFilterType::Pointer gaussianFilter2 = GaussFilterType::New(); gaussianFilter2->SetInput( itkImage ); gaussianFilter2->SetVariance(variance*0.66*0.66); gaussianFilter2->Update(); typename SubFilterType::Pointer subFilter = SubFilterType::New(); subFilter->SetInput1(gaussianFilter1->GetOutput()); subFilter->SetInput2(gaussianFilter2->GetOutput()); subFilter->Update(); mitk::CastToMitkImage(subFilter->GetOutput(), output); } template void LaplacianOfGaussianFilter(itk::Image* itkImage, double variance, mitk::Image::Pointer &output) { typedef itk::Image ImageType; typedef itk::DiscreteGaussianImageFilter< ImageType, ImageType > GaussFilterType; typedef itk::LaplacianRecursiveGaussianImageFilter LaplacianFilter; typename GaussFilterType::Pointer gaussianFilter = GaussFilterType::New(); gaussianFilter->SetInput( itkImage ); gaussianFilter->SetVariance(variance); gaussianFilter->Update(); typename LaplacianFilter::Pointer laplaceFilter = LaplacianFilter::New(); laplaceFilter->SetInput(gaussianFilter->GetOutput()); laplaceFilter->Update(); mitk::CastToMitkImage(laplaceFilter->GetOutput(), output); } template void HessianOfGaussianFilter(itk::Image* itkImage, double variance, std::vector &out) { typedef itk::Image ImageType; typedef itk::Image FloatImageType; typedef itk::HessianRecursiveGaussianImageFilter HessianFilterType; typedef typename HessianFilterType::OutputImageType VectorImageType; typedef Functor::MatrixFirstEigenvalue DeterminantFunctorType; typedef itk::UnaryFunctorImageFilter DetFilterType; typename HessianFilterType::Pointer hessianFilter = HessianFilterType::New(); hessianFilter->SetInput(itkImage); hessianFilter->SetSigma(std::sqrt(variance)); for (unsigned int i = 0; i < VImageDimension; ++i) { typename DetFilterType::Pointer detFilter = DetFilterType::New(); detFilter->SetInput(hessianFilter->GetOutput()); detFilter->GetFunctor().order = i; detFilter->Update(); mitk::CastToMitkImage(detFilter->GetOutput(), out[i]); } } template void LocalHistograms(itk::Image* itkImage, std::vector &out, double offset, double delta) { typedef itk::Image ImageType; typedef itk::MultiHistogramFilter MultiHistogramType; typename MultiHistogramType::Pointer filter = MultiHistogramType::New(); filter->SetInput(itkImage); filter->SetOffset(offset); filter->SetDelta(delta); filter->Update(); for (int i = 0; i < 11; ++i) { mitk::Image::Pointer img = mitk::Image::New(); mitk::CastToMitkImage(filter->GetOutput(i), img); out.push_back(img); } } int main(int argc, char* argv[]) { mitkCommandLineParser parser; parser.setArgumentPrefix("--", "-"); // required params parser.addArgument("image", "i", mitkCommandLineParser::InputImage, "Input Image", "Path to the input VTK polydata", us::Any(), false); parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output text file", "Target file. The output statistic is appended to this file.", us::Any(), false); parser.addArgument("extension", "e", mitkCommandLineParser::OutputFile, "Extension", "File extension. Default is .nii.gz", us::Any(), true); parser.addArgument("gaussian","g",mitkCommandLineParser::String, "Gaussian Filtering of the input images", "Gaussian Filter. Followed by the used variances seperated by ';' ",us::Any()); parser.addArgument("difference-of-gaussian","dog",mitkCommandLineParser::String, "Difference of Gaussian Filtering of the input images", "Difference of Gaussian Filter. Followed by the used variances seperated by ';' ",us::Any()); parser.addArgument("laplace-of-gauss","log",mitkCommandLineParser::String, "Laplacian of Gaussian Filtering", "Laplacian of Gaussian Filter. Followed by the used variances seperated by ';' ",us::Any()); parser.addArgument("hessian-of-gauss","hog",mitkCommandLineParser::String, "Hessian of Gaussian Filtering", "Hessian of Gaussian Filter. Followed by the used variances seperated by ';' ",us::Any()); parser.addArgument("local-histogram", "lh", mitkCommandLineParser::String, "Local Histograms", "Calculate the local histogram based feature. Specify Offset and Delta, for exampel -3;0.6 ", us::Any()); // Miniapp Infos parser.setCategory("Classification Tools"); parser.setTitle("Global Image Feature calculator"); parser.setDescription("Calculates different global statistics for a given segmentation / image combination"); parser.setContributor("MBI"); std::map parsedArgs = parser.parseArguments(argc, argv); if (parsedArgs.size()==0) { return EXIT_FAILURE; } if ( parsedArgs.count("help") || parsedArgs.count("h")) { return EXIT_SUCCESS; } mitk::Image::Pointer image = dynamic_cast(mitk::IOUtil::Load(parsedArgs["image"].ToString())[0].GetPointer()); std::string filename=parsedArgs["output"].ToString(); std::string extension = ".nii.gz"; if (parsedArgs.count("extension")) { extension = parsedArgs["extension"].ToString(); } //////////////////////////////////////////////////////////////// // CAlculate Gaussian Features //////////////////////////////////////////////////////////////// MITK_INFO << "Check for Local Histogram..."; if (parsedArgs.count("local-histogram")) { std::vector outs; auto ranges = splitDouble(parsedArgs["local-histogram"].ToString(), ';'); if (ranges.size() < 2) { MITK_INFO << "Missing Delta and Offset for Local Histogram"; } else { AccessByItk_3(image, LocalHistograms, outs, ranges[0], ranges[1]); for (std::size_t i = 0; i < outs.size(); ++i) { std::string name = filename + "-lh" + us::any_value_to_string(i)+extension; mitk::IOUtil::Save(outs[i], name); } } } //////////////////////////////////////////////////////////////// // CAlculate Gaussian Features //////////////////////////////////////////////////////////////// MITK_INFO << "Check for Gaussian..."; if (parsedArgs.count("gaussian")) { MITK_INFO << "Calculate Gaussian... " << parsedArgs["gaussian"].ToString(); auto ranges = splitDouble(parsedArgs["gaussian"].ToString(),';'); for (std::size_t i = 0; i < ranges.size(); ++i) { MITK_INFO << "Gaussian with sigma: " << ranges[i]; mitk::Image::Pointer output; AccessByItk_2(image, GaussianFilter, ranges[i], output); MITK_INFO << "Write output:"; std::string name = filename + "-gaussian-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::SaveImage(output, name); } } //////////////////////////////////////////////////////////////// // CAlculate Difference of Gaussian Features //////////////////////////////////////////////////////////////// MITK_INFO << "Check for DoG..."; if (parsedArgs.count("difference-of-gaussian")) { MITK_INFO << "Calculate Difference of Gaussian... " << parsedArgs["difference-of-gaussian"].ToString(); auto ranges = splitDouble(parsedArgs["difference-of-gaussian"].ToString(),';'); for (std::size_t i = 0; i < ranges.size(); ++i) { mitk::Image::Pointer output; AccessByItk_2(image, DifferenceOfGaussFilter, ranges[i], output); std::string name = filename + "-dog-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::Save(output, name); } } MITK_INFO << "Check for LoG..."; //////////////////////////////////////////////////////////////// // CAlculate Laplacian Of Gauss Features //////////////////////////////////////////////////////////////// if (parsedArgs.count("laplace-of-gauss")) { MITK_INFO << "Calculate LoG... " << parsedArgs["laplace-of-gauss"].ToString(); auto ranges = splitDouble(parsedArgs["laplace-of-gauss"].ToString(),';'); for (std::size_t i = 0; i < ranges.size(); ++i) { mitk::Image::Pointer output; AccessByItk_2(image, LaplacianOfGaussianFilter, ranges[i], output); std::string name = filename + "-log-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::Save(output, name); } } MITK_INFO << "Check for HoG..."; //////////////////////////////////////////////////////////////// // CAlculate Hessian Of Gauss Features //////////////////////////////////////////////////////////////// if (parsedArgs.count("hessian-of-gauss")) { MITK_INFO << "Calculate HoG... " << parsedArgs["hessian-of-gauss"].ToString(); auto ranges = splitDouble(parsedArgs["hessian-of-gauss"].ToString(),';'); for (std::size_t i = 0; i < ranges.size(); ++i) { std::vector outs; outs.push_back(mitk::Image::New()); outs.push_back(mitk::Image::New()); outs.push_back(mitk::Image::New()); AccessByItk_2(image, HessianOfGaussianFilter, ranges[i], outs); std::string name = filename + "-hog0-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::Save(outs[0], name); name = filename + "-hog1-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::Save(outs[1], name); name = filename + "-hog2-" + us::any_value_to_string(ranges[i]) + extension; mitk::IOUtil::Save(outs[2], name); } } return 0; } #endif diff --git a/Modules/Classification/CLMiniApps/CMakeLists.txt b/Modules/Classification/CLMiniApps/CMakeLists.txt index dd7fe57d46..1978c241e3 100644 --- a/Modules/Classification/CLMiniApps/CMakeLists.txt +++ b/Modules/Classification/CLMiniApps/CMakeLists.txt @@ -1,141 +1,145 @@ 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 - CLGlobalImageFeatures^^MitkCore_MitkCLUtilities_MitkQtWidgetsExt - CLMRNormalization^^MitkCore_MitkCLUtilities_MitkCLMRUtilities - CLStaple^^MitkCore_MitkCLUtilities - CLVoxelFeatures^^MitkCore_MitkCLUtilities CLDicom2Nrrd^^MitkCore - CLPolyToNrrd^^MitkCore CLImageTypeConverter^^MitkCore CLResampleImageToReference^^MitkCore + CLGlobalImageFeatures^^MitkCLUtilities + CLMRNormalization^^MitkCLUtilities_MitkCLMRUtilities + CLStaple^^MitkCLUtilities + CLVoxelFeatures^^MitkCLUtilities + CLPolyToNrrd^^ + CLSimpleVoxelClassification^^MitkDataCollection_MitkCLVigraRandomForest + CLVoxelClassification^^MitkDataCollection_MitkCLImportanceWeighting_MitkCLVigraRandomForest + CLBrainMask^^MitkCLUtilities + XRaxSimulationFromCT^^MitkCLUtilities CLRandomSampling^^MitkCore_MitkCLUtilities CLRemoveEmptyVoxels^^MitkCore CLN4^^MitkCore 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(CLGlobalImageFeatures # DEPENDS MitkCore MitkCLUtilities # CPP_FILES CLGlobalImageFeatures.cpp mitkCommandLineParser.cpp #) mitk_create_executable(CLSimpleVoxelClassification DEPENDS MitkCore MitkCLCore MitkDataCollection MitkCLVigraRandomForest MitkCommandLine CPP_FILES CLSimpleVoxelClassification.cpp ) # This mini app does not depend on mitkDiffusionImaging at all mitk_create_executable(CLVoxelClassification DEPENDS MitkCore MitkCLCore MitkDataCollection MitkCLImportanceWeighting MitkCLVigraRandomForest CPP_FILES CLVoxelClassification.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/Classification/CLMiniApps/XRaxSimulationFromCT.cpp b/Modules/Classification/CLMiniApps/XRaxSimulationFromCT.cpp new file mode 100644 index 0000000000..c951097f72 --- /dev/null +++ b/Modules/Classification/CLMiniApps/XRaxSimulationFromCT.cpp @@ -0,0 +1,198 @@ +/*=================================================================== + +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 "mitkDicomSeriesReader.h" +#include "mitkProperties.h" + +#include "mitkCommandLineParser.h" +#include "mitkIOUtil.h" + +#include "itkImageRegionIterator.h" +// MITK +#include +#include +#include + + + +template +void +CreateXRay(itk::Image* itkImage, mitk::Image::Pointer mask1, std::string output) +{ + typedef itk::Image ImageType; + typedef itk::Image MaskType; + typedef itk::Image NewImageType; + + typename MaskType::Pointer itkMask = MaskType::New(); + mitk::CastToItkImage(mask1, itkMask); + + NewImageType::SpacingType newSpacing; + auto spacing = itkImage->GetSpacing(); + + NewImageType::RegionType region1,region2,region3,region1m,region2m,region3m; + NewImageType::IndexType start; + start[0] = 0; start[1] = 0; + + NewImageType::SizeType size1, size2, size3; + size1[0] = mask1->GetDimensions()[0]; + size2[0] = mask1->GetDimensions()[0]; + size3[0] = mask1->GetDimensions()[1]; + size1[1] = mask1->GetDimensions()[1]; + size2[1] = mask1->GetDimensions()[2]; + size3[1] = mask1->GetDimensions()[2]; + + region1.SetSize(size1); + region1m.SetSize(size1); + region2.SetSize(size2); + region2m.SetSize(size2); + region3.SetSize(size3); + region3m.SetSize(size3); + region1.SetIndex(start); + region1m.SetIndex(start); + region2.SetIndex(start); + region2m.SetIndex(start); + region3.SetIndex(start); + region3m.SetIndex(start); + + NewImageType::Pointer image1 = NewImageType::New(); + image1->SetRegions(region1); + image1->Allocate(); + image1->FillBuffer(0); + newSpacing[0] = spacing[0]; newSpacing[1] = spacing[1]; + image1->SetSpacing(newSpacing); + NewImageType::Pointer image2 = NewImageType::New(); + image2->SetRegions(region2); + image2->Allocate(); + image2->FillBuffer(0); + newSpacing[0] = spacing[0]; newSpacing[1] = spacing[2]; + image2->SetSpacing(newSpacing); + NewImageType::Pointer image3 = NewImageType::New(); + image3->SetRegions(region3); + image3->Allocate(); + image3->FillBuffer(0); + newSpacing[0] = spacing[1]; newSpacing[1] = spacing[2]; + image3->SetSpacing(newSpacing); + NewImageType::Pointer image1m = NewImageType::New(); + image1m->SetRegions(region1m); + image1m->Allocate(); + image1m->FillBuffer(0); + newSpacing[0] = spacing[0]; newSpacing[1] = spacing[1]; + image1m->SetSpacing(newSpacing); + NewImageType::Pointer image2m = NewImageType::New(); + image2m->SetRegions(region2m); + image2m->Allocate(); + image2m->FillBuffer(0); + newSpacing[0] = spacing[0]; newSpacing[1] = spacing[2]; + image2m->SetSpacing(newSpacing); + NewImageType::Pointer image3m = NewImageType::New(); + image3m->SetRegions(region3m); + image3m->Allocate(); + image3m->FillBuffer(0); + newSpacing[0] = spacing[1]; newSpacing[1] = spacing[2]; + image3m->SetSpacing(newSpacing); + + for (int x = 0; x < mask1->GetDimensions()[0]; ++x) + { + for (int y = 0; y < mask1->GetDimensions()[1]; ++y) + { + for (int z = 0; z < mask1->GetDimensions()[2]; ++z) + { + NewImageType::IndexType newIndex; + ImageType::IndexType index; + index[0] = x; index[1] = y; index[2] = z; + double pixel = itkImage->GetPixel(index)+1024; + pixel = pixel / 1000.0; + newIndex[0] = x; newIndex[1] = y; + image1->SetPixel(newIndex, image1->GetPixel(newIndex) + pixel); + newIndex[0] = x; newIndex[1] = z; + image2->SetPixel(newIndex, image2->GetPixel(newIndex) + pixel); + newIndex[0] = y; newIndex[1] = z; + image3->SetPixel(newIndex, image3->GetPixel(newIndex) + pixel); + if (itkMask->GetPixel(index) > 0) + { + pixel = -1000 + 1024; + pixel = pixel / 1000.0; + } + newIndex[0] = x; newIndex[1] = y; + image1m->SetPixel(newIndex, image1m->GetPixel(newIndex) + pixel); + newIndex[0] = x; newIndex[1] = z; + image2m->SetPixel(newIndex, image2m->GetPixel(newIndex) + pixel); + newIndex[0] = y; newIndex[1] = z; + image3m->SetPixel(newIndex, image3m->GetPixel(newIndex) + pixel); + } + } + } + + + mitk::Image::Pointer img = mitk::ImportItkImage(image1); + mitk::IOUtil::SaveImage(img, output + "1.nrrd"); + img = mitk::ImportItkImage(image2); + mitk::IOUtil::SaveImage(img, output + "2.nrrd"); + img = mitk::ImportItkImage(image3); + mitk::IOUtil::SaveImage(img, output + "3.nrrd"); + img = mitk::ImportItkImage(image1m); + mitk::IOUtil::SaveImage(img, output + "1m.nrrd"); + img = mitk::ImportItkImage(image2m); + mitk::IOUtil::SaveImage(img, output + "2m.nrrd"); + img = mitk::ImportItkImage(image3m); + mitk::IOUtil::SaveImage(img, output + "3m.nrrd"); +} + +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 image:", "Input folder", us::Any(), false); + parser.addArgument("mask", "m", mitkCommandLineParser::InputDirectory, "Input mask:", "Input folder", 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 inputImage = us::any_cast(parsedArgs["input"]); + MITK_INFO << inputImage; + std::string inputMask = us::any_cast(parsedArgs["mask"]); + MITK_INFO << inputMask; + + mitk::Image::Pointer image = mitk::IOUtil::LoadImage(inputImage); + mitk::Image::Pointer mask = mitk::IOUtil::LoadImage(inputMask); + + AccessByItk_2(image, CreateXRay, mask, parsedArgs["output"].ToString()); + + //const mitk::Image::Pointer image = *imageIter; + //mitk::IOUtil::SaveImage(image,outFileName); + + + + return EXIT_SUCCESS; +} diff --git a/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.cpp b/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.cpp index 5c43dc8ddb..544ee43a67 100644 --- a/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.cpp +++ b/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.cpp @@ -1,105 +1,113 @@ #ifndef itkMultiHistogramFilter_cpp #define itkMultiHistogramFilter_cpp #include #include #include #include +#include "itkMinimumMaximumImageCalculator.h" template< class TInputImageType, class TOuputImageType> itk::MultiHistogramFilter::MultiHistogramFilter(): - m_Delta(0.6), m_Offset(-3.0) +m_Offset(-3.0), m_Delta(0.6), m_Bins(11), m_Size(5), m_UseImageIntensityRange(false) { - this->SetNumberOfRequiredOutputs(11); + this->SetNumberOfRequiredOutputs(m_Bins); this->SetNumberOfRequiredInputs(0); - for (unsigned int i = 0; i < 11; ++i) + for (int i = 0; i < m_Bins; ++i) { this->SetNthOutput( i, this->MakeOutput(i) ); } } template< class TInputImageType, class TOuputImageType> void itk::MultiHistogramFilter::BeforeThreadedGenerateData() { -// MITK_INFO << "Creating output images"; + typedef itk::MinimumMaximumImageCalculator + ImageCalculatorFilterType; + + if (m_UseImageIntensityRange) + { + ImageCalculatorFilterType::Pointer imageCalculatorFilter + = ImageCalculatorFilterType::New(); + imageCalculatorFilter->SetImage(this->GetInput(0)); + imageCalculatorFilter->Compute(); + + offset = imageCalculatorFilter->GetMinimum(); + delta = 1.0*(imageCalculatorFilter->GetMaximum() - imageCalculatorFilter->GetMinimum()) / (1.0*m_Bins); + } + + std::cout << "Offset: " << offset << " delta: " << delta << std::endl; + InputImagePointer input = this->GetInput(0); - CreateOutputImage(input, this->GetOutput(0)); - CreateOutputImage(input, this->GetOutput(1)); - CreateOutputImage(input, this->GetOutput(2)); - CreateOutputImage(input, this->GetOutput(3)); - CreateOutputImage(input, this->GetOutput(4)); - CreateOutputImage(input, this->GetOutput(5)); - CreateOutputImage(input, this->GetOutput(6)); - CreateOutputImage(input, this->GetOutput(7)); - CreateOutputImage(input, this->GetOutput(8)); - CreateOutputImage(input, this->GetOutput(9)); - CreateOutputImage(input, this->GetOutput(10)); + for (int i = 0; i < m_Bins; ++i) + { + CreateOutputImage(input, this->GetOutput(i)); + } } template< class TInputImageType, class TOuputImageType> void itk::MultiHistogramFilter::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) { double offset = m_Offset;// -3.0; double delta = m_Delta;// 0.6; typedef itk::ImageRegionIterator IteratorType; typedef itk::ConstNeighborhoodIterator ConstIteratorType; - InputImagePointer input = this->GetInput(0); + typename TInputImageType::SizeType size; size.Fill(m_Size); // MITK_INFO << "Creating output iterator"; - typename TInputImageType::SizeType size; size.Fill(5); std::vector iterVector; - for (int i = 0; i < 11; ++i) + for (int i = 0; i < m_Bins; ++i) { IteratorType iter(this->GetOutput(i), outputRegionForThread); iterVector.push_back(iter); } ConstIteratorType inputIter(size, input, outputRegionForThread); while (!inputIter.IsAtEnd()) { - for (unsigned int i = 0; i < 11; ++i) + for (int i = 0; i < m_Bins; ++i) { iterVector[i].Set(0); } for (unsigned int i = 0; i < inputIter.Size(); ++i) { double value = inputIter.GetPixel(i); value -= offset; value /= delta; int pos = (int)(value); - pos = std::max(0, std::min(10, pos)); + pos = std::max(0, std::min(m_Bins-1, pos)); iterVector[pos].Value() += 1;// (iterVector[pos].GetCenterPixel() + 1); } - for (unsigned int i = 0; i < 11; ++i) + for (int i = 0; i < m_Bins; ++i) { ++(iterVector[i]); } ++inputIter; } } template< class TInputImageType, class TOuputImageType> itk::ProcessObject::DataObjectPointer itk::MultiHistogramFilter::MakeOutput(itk::ProcessObject::DataObjectPointerArraySizeType /*idx*/) { itk::ProcessObject::DataObjectPointer output; output = ( TOuputImageType::New() ).GetPointer(); return output; } template< class TInputImageType, class TOuputImageType> void itk::MultiHistogramFilter::CreateOutputImage(InputImagePointer input, OutputImagePointer output) { output->SetRegions(input->GetLargestPossibleRegion()); output->Allocate(); } #endif //itkMultiHistogramFilter_cpp diff --git a/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.h b/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.h index 826649fb40..9ec7319a63 100644 --- a/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.h +++ b/Modules/Classification/CLUtilities/include/itkMultiHistogramFilter.h @@ -1,54 +1,66 @@ #ifndef itkMultiHistogramFilter_h #define itkMultiHistogramFilter_h #include "itkImageToImageFilter.h" namespace itk { template class MultiHistogramFilter : public ImageToImageFilter< TInputImageType, TOuputImageType> { public: typedef MultiHistogramFilter Self; typedef ImageToImageFilter< TInputImageType, TOuputImageType > Superclass; typedef SmartPointer< Self > Pointer; typedef typename TInputImageType::ConstPointer InputImagePointer; typedef typename TOuputImageType::Pointer OutputImagePointer; typedef typename TOuputImageType::RegionType OutputImageRegionType; itkNewMacro (Self); itkTypeMacro(MultiHistogramFilter, ImageToImageFilter); itkSetMacro(Delta, double); itkGetConstMacro(Delta, double); itkSetMacro(Offset, double); itkGetConstMacro(Offset, double); + itkSetMacro(Bins, int); + itkGetConstMacro(Bins, int); + + itkSetMacro(Size, int); + itkGetConstMacro(Size, int); + + itkSetMacro(UseImageIntensityRange, bool); + itkGetConstMacro(UseImageIntensityRange, bool); + protected: MultiHistogramFilter(); ~MultiHistogramFilter(){}; virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId); virtual void BeforeThreadedGenerateData(void); using itk::ProcessObject::MakeOutput; virtual itk::ProcessObject::DataObjectPointer MakeOutput(itk::ProcessObject::DataObjectPointerArraySizeType /*idx*/) override; void CreateOutputImage(InputImagePointer input, OutputImagePointer output); private: MultiHistogramFilter(const Self &); // purposely not implemented void operator=(const Self &); // purposely not implemented double m_Delta; double m_Offset; + int m_Bins; + int m_Size; + bool m_UseImageIntensityRange; }; } #ifndef ITK_MANUAL_INSTANTIATION #include "itkMultiHistogramFilter.cpp" #endif #endif // itkMultiHistogramFilter_h diff --git a/Modules/Classification/CLUtilities/include/mitkCLUtil.h b/Modules/Classification/CLUtilities/include/mitkCLUtil.h index 868ecd6069..6396455675 100644 --- a/Modules/Classification/CLUtilities/include/mitkCLUtil.h +++ b/Modules/Classification/CLUtilities/include/mitkCLUtil.h @@ -1,526 +1,571 @@ #ifndef mitkCLUtil_h #define mitkCLUtil_h #include #include #include #include #include #include #include namespace mitk { class MITKCLUTILITIES_EXPORT CLUtil { public: /// /// \brief The MorphologicalDimensions enum /// enum MorphologicalDimensions { Axial,Coronal,Sagital,All }; /// /// \brief CreateCheckerBoardPredictionMask /// \param image /// \param outimage /// static void CreateCheckerboardMask(mitk::Image::Pointer image, mitk::Image::Pointer & outimage); /// /// \brief InterpolateCreateCheckerboardPrediction /// \param image /// \param outimage /// static void InterpolateCheckerboardPrediction(mitk::Image::Pointer checkerboard_prediction, mitk::Image::Pointer & checkerboard_mask, mitk::Image::Pointer & outimage); /// /// \brief CountVoxel /// \param image /// \param map /// static void CountVoxel(mitk::Image::Pointer image, std::map & map); /// /// \brief CountVoxel /// \param image /// \param label /// \param count /// static void CountVoxel(mitk::Image::Pointer image, unsigned int label, unsigned int & count); /// /// \brief CountVoxel /// \param image /// \param count /// static void CountVoxel(mitk::Image::Pointer image, unsigned int & count); /// /// \brief SumVoxelForLabel /// \param image /// \param source /// \param label /// \param val /// static void SumVoxelForLabel(mitk::Image::Pointer image, const mitk::Image::Pointer & source , unsigned int label, double & val ); /// /// \brief SqSumVoxelForLabel /// \param image /// \param source /// \param label /// \param val /// static void SqSumVoxelForLabel(mitk::Image::Pointer image, const mitk::Image::Pointer & source, unsigned int label, double & val ); /// /// \brief LogicalAndImages /// \param image1 /// \param image2 /// static void LogicalAndImages(const Image::Pointer &image1, const Image::Pointer &image2, Image::Pointer &outimage); /// /// \brief GaussianFilter /// \param image /// \param smoothed /// \param sigma /// static void GaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed ,double sigma); + /// + /// \brief SubtractGaussianFilter + /// \param image + /// \param smoothed (Result is sigma1-sigma2) + /// \param sigma1 + /// \param sigma2 + /// + static void DifferenceOfGaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed, double sigma1, double sigma2); + + /// + /// \brief Laplacian of Gaussian + /// \param image + /// \param smoothed (Result is sigma1-sigma2) + /// \param sigma1 + /// \param sigma2 + /// + static void LaplacianOfGaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed, double sigma1); + + /// + /// \brief SubtractGaussianFilter + /// \param image + /// \param smoothed (Result is sigma1-sigma2) + /// \param sigma1 + /// \param sigma2 + /// + static void HessianOfGaussianFilter(mitk::Image::Pointer image, std::vector &out, double sigma); + + /// + /// \brief Local Histogram + /// \param image + /// \param smoothed (Result is sigma1-sigma2) + /// \param sigma1 + /// \param sigma2 + /// + static void LocalHistogram(mitk::Image::Pointer image, std::vector &out, int Bins, int NeighbourhoodSize); + /// /// \brief transform /// \param matrix /// \param mask /// \param outimage /// template static mitk::Image::Pointer Transform(const Eigen::Matrix & matrix, const mitk::Image::Pointer & mask) { itk::Image::Pointer itkMask; mitk::CastToItkImage(mask,itkMask); typename itk::Image::Pointer itk_img = itk::Image::New(); itk_img->SetRegions(itkMask->GetLargestPossibleRegion()); itk_img->SetOrigin(itkMask->GetOrigin()); itk_img->SetSpacing(itkMask->GetSpacing()); itk_img->SetDirection(itkMask->GetDirection()); itk_img->Allocate(); unsigned int n_numSamples = 0; mitk::CLUtil::CountVoxel(mask,n_numSamples); if(n_numSamples != matrix.rows()) MITK_ERROR << "Number of samples in matrix and number of points under the masks is not the same!"; auto mit = itk::ImageRegionConstIterator >(itkMask, itkMask->GetLargestPossibleRegion()); auto oit = itk::ImageRegionIterator >(itk_img, itk_img->GetLargestPossibleRegion()); unsigned int current_row = 0; while(!mit.IsAtEnd()) { if(mit.Value() > 0) oit.Set(matrix(current_row++,0)); else oit.Set(0.0); ++mit; ++oit; } mitk::Image::Pointer out_img = mitk::Image::New(); mitk::GrabItkImageMemory(itk_img,out_img); return out_img; } /// /// \brief TransformImageToMatrix /// \param in_img /// \param mask /// \param out_matrix /// template static Eigen::Matrix Transform(const mitk::Image::Pointer & img, const mitk::Image::Pointer & mask) { itk::Image::Pointer current_mask; mitk::CastToItkImage(mask,current_mask); unsigned int n_numSamples = 0; mitk::CLUtil::CountVoxel(mask,n_numSamples); typename itk::Image::Pointer current_img; mitk::CastToItkImage(img,current_img); Eigen::Matrix out_matrix(n_numSamples,1); auto mit = itk::ImageRegionConstIterator >(current_mask, current_mask->GetLargestPossibleRegion()); auto iit = itk::ImageRegionConstIterator >(current_img,current_img->GetLargestPossibleRegion()); unsigned int current_row = 0; while (!mit.IsAtEnd()) { if(mit.Value() > 0) out_matrix(current_row++) = iit.Value(); ++mit; ++iit; } return out_matrix; } /// /// \brief DilateBinary /// \param BinaryImage /// \param BinaryImage /// \param Size of the StructuringElement /// \param Dimension /// static void DilateBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int radius , MorphologicalDimensions d); /// /// \brief ErodeBinary /// \param BinaryImage /// \param BinaryImage /// \param Size of the StructuringElement /// \param Dimension /// static void ErodeBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int radius, MorphologicalDimensions d); /// /// \brief ClosingBinary /// \param BinaryImage /// \param BinaryImage /// \param Size of the StructuringElement /// \param Dimension /// static void ClosingBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int radius, MorphologicalDimensions d); /// /// \brief MergeLabels /// \param MultilabelImage /// \param map merge instruction where each map entry defines a mapping instruction. Key - Value /// static void MergeLabels(mitk::Image::Pointer & img, const std::map & map); /// /// \brief ConnectedComponentsImage /// \param BinaryImage /// \param BinaryImage /// \param MultilabelImage /// \param Number of components found in the image /// static void ConnectedComponentsImage(mitk::Image::Pointer & image, mitk::Image::Pointer& mask, mitk::Image::Pointer &outimage, unsigned int& num_components); /// /// \brief GrabLabel /// \param MultiLabelImage /// \param outimage /// \param label /// static void GrabLabel(mitk::Image::Pointer & image, mitk::Image::Pointer & outimage, unsigned int label); /// /// \brief itkInsertLabel /// \param image /// \param maskImage /// \param label /// static void InsertLabel(mitk::Image::Pointer & image, mitk::Image::Pointer & maskImage, unsigned int label); /// /// \brief ErodeGrayscale /// \param image /// \param outimage /// \param radius /// \param d /// static void ErodeGrayscale(mitk::Image::Pointer & image, unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer & outimage ); /// /// \brief DilateGrayscale /// \param image /// \param outimage /// \param radius /// \param d /// static void DilateGrayscale(mitk::Image::Pointer & image, unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer & outimage ); /// /// \brief FillHoleGrayscale /// \param image /// \param outimage /// static void FillHoleGrayscale(mitk::Image::Pointer & image, mitk::Image::Pointer & outimage); /// /// \brief ProbabilityMap /// \param sourceImage /// \param mean /// \param std_dev /// \param resultImage /// static void ProbabilityMap(const mitk::Image::Pointer& sourceImage, double mean, double std_dev, mitk::Image::Pointer& resultImage); template static void itkCountVoxel( TImageType * image, std::map & map) { auto it = itk::ImageRegionIterator< TImageType >(image,image->GetLargestPossibleRegion()); while(!it.IsAtEnd()) { if(map.find(it.Value()) == map.end()) map[it.Value()] = 0; map[it.Value()]++; ++it; } } template static void itkCountVoxel(TImageType* image, typename TImageType::PixelType label, unsigned int & count ) { itk::ImageRegionConstIterator inputIter(image, image->GetLargestPossibleRegion()); while(!inputIter.IsAtEnd()) { if(inputIter.Value() == label) ++count; ++inputIter; } } template static inline void itkCountVoxel(TImageType * mask, unsigned int & n_numSamples) { auto mit = itk::ImageRegionConstIterator(mask, mask->GetLargestPossibleRegion()); while (!mit.IsAtEnd()) { if(mit.Value() > 0) n_numSamples++; ++mit; } } template static void itkSampleLabel(TImageType1* image, TImageType2* output, double acceptrate, unsigned int label) { std::srand (time(nullptr)); itk::ImageRegionConstIterator< TImageType1 > inputIter(image, image->GetLargestPossibleRegion()); itk::ImageRegionIterator< TImageType2 > outputIter(output, output->GetLargestPossibleRegion()); while (!inputIter.IsAtEnd()) { double r = (double)(rand()) / RAND_MAX; if(inputIter.Get() == label && r < acceptrate) outputIter.Set(label); ++inputIter; ++outputIter; } } template static void itkSampleLabel(TImageType* image, mitk::Image::Pointer & output, unsigned int n_samples_drawn) { std::srand (time(nullptr)); typename TImageType::Pointer itk_out = TImageType::New(); itk_out->SetRegions(image->GetLargestPossibleRegion()); itk_out->SetDirection(image->GetDirection()); itk_out->SetOrigin(image->GetOrigin()); itk_out->SetSpacing(image->GetSpacing()); itk_out->Allocate(); itk_out->FillBuffer(0); itk::ImageRegionConstIterator< TImageType > inputIter(image, image->GetLargestPossibleRegion()); itk::ImageRegionIterator< TImageType > outputIter(itk_out, itk_out->GetLargestPossibleRegion()); for(unsigned int i = 0 ; i < n_samples_drawn ;) { double r = (double)(rand()) / RAND_MAX; if(inputIter.Value() != 0 && r < 0.01 && outputIter.Value() == 0) { outputIter.Set(inputIter.Value()); i++; } ++inputIter; ++outputIter; if(inputIter.IsAtEnd()) { inputIter.GoToBegin(); outputIter.GoToBegin(); } } mitk::CastToMitkImage(itk_out, output); } private: template static void itkErodeGrayscale(TImageType * image, mitk::Image::Pointer & outimage , unsigned int radius, mitk::CLUtil::MorphologicalDimensions d); template static void itkDilateGrayscale(TImageType * image, mitk::Image::Pointer & outimage , unsigned int radius, mitk::CLUtil::MorphologicalDimensions d); template static void itkFillHoleGrayscale(TImageType * image, mitk::Image::Pointer & outimage); template< typename TImageType > static void itkInsertLabel(TImageType * maskImage, mitk::Image::Pointer & outimage, unsigned int label) { typename TImageType::Pointer itk_out; if(outimage.IsNull()) // create if necessary { MITK_INFO << "Initialize new image"; itk_out = TImageType::New(); itk_out->SetSpacing(maskImage->GetSpacing()); itk_out->SetDirection(maskImage->GetDirection()); itk_out->SetOrigin(maskImage->GetOrigin()); itk_out->SetRegions(maskImage->GetLargestPossibleRegion()); itk_out->Allocate(); itk_out->FillBuffer(0); }else { mitk::CastToItkImage(outimage, itk_out); } itk::ImageRegionIterator oit(itk_out,itk_out->GetLargestPossibleRegion()); itk::ImageRegionConstIterator mit(maskImage,maskImage->GetLargestPossibleRegion()); while(!mit.IsAtEnd()) { if(mit.Value() != 0) { oit.Set(label); } ++oit; ++mit; } mitk::CastToMitkImage(itk_out,outimage); } template< typename TImageType > static void itkGrabLabel(TImageType * image, mitk::Image::Pointer & outimage, unsigned int label) { typedef itk::Image TOutType; TOutType::Pointer itk_out = TOutType::New(); itk_out->SetRegions(image->GetLargestPossibleRegion()); itk_out->SetDirection(image->GetDirection()); itk_out->SetOrigin(image->GetOrigin()); itk_out->SetSpacing(image->GetSpacing()); itk_out->Allocate(); itk::ImageRegionConstIterator iit(image, image->GetLargestPossibleRegion()); itk::ImageRegionIterator oit(itk_out,itk_out->GetLargestPossibleRegion()); while(!iit.IsAtEnd()) { if(iit.Value() == static_cast(label)) oit.Set(1); else oit.Set(0); ++iit; ++oit; } mitk::CastToMitkImage(itk_out, outimage); } template static void itkMergeLabels(TImagetype * img, const std::map & map) { auto it = itk::ImageRegionIterator(img,img->GetLargestPossibleRegion()); while(!it.IsAtEnd()) { if(map.find(it.Value())!=map.end()) it.Set( map.at(it.Value()) ); ++it; } } template static void itkConnectedComponentsImage(TImageType * image, mitk::Image::Pointer& mask, mitk::Image::Pointer &outimage, unsigned int& num_components) { typedef itk::Image MaskImageType; MaskImageType::Pointer itk_mask; if(mask.IsNull()) { itk_mask = MaskImageType::New(); itk_mask->SetRegions(image->GetLargestPossibleRegion()); itk_mask->SetDirection(image->GetDirection()); itk_mask->SetOrigin(image->GetOrigin()); itk_mask->SetSpacing(image->GetSpacing()); itk_mask->Allocate(); itk_mask->FillBuffer(1); }else{ mitk::CastToItkImage(mask,itk_mask); } typedef itk::ConnectedComponentImageFilter FilterType; typename FilterType::Pointer cc_filter = FilterType::New(); cc_filter->SetMaskImage(itk_mask.GetPointer()); cc_filter->SetInput(image); cc_filter->SetBackgroundValue(0); cc_filter->Update(); num_components = cc_filter->GetObjectCount(); mitk::CastToMitkImage(cc_filter->GetOutput(), outimage); } template< typename TImageType > static void itkCreateCheckerboardMask(TImageType * image, mitk::Image::Pointer & outimage); template< typename TImageType > static void itkInterpolateCheckerboardPrediction(TImageType * checkerboard_prediction, mitk::Image::Pointer & checkerboard_mask, mitk::Image::Pointer & outimage); template static void itkSumVoxelForLabel(TImageType* image, const mitk::Image::Pointer & source , typename TImageType::PixelType label, double & val ); template static void itkSqSumVoxelForLabel(TImageType* image, const mitk::Image::Pointer & source, typename TImageType::PixelType label, double & val ); template static void itkFitStructuringElement(TStructuringElement & se, MorphologicalDimensions d, int radius); template static void itkDilateBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int radius , MorphologicalDimensions d); template static void itkErodeBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int radius, MorphologicalDimensions d); template static void itkClosingBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int radius, MorphologicalDimensions d); template static void itkFillHolesBinary(itk::Image* sourceImage, mitk::Image::Pointer& resultImage); template static void itkLogicalAndImages(const TImageType * image1, const mitk::Image::Pointer & image2, mitk::Image::Pointer & outimage); template static void itkGaussianFilter(TImageType * image, mitk::Image::Pointer & smoothed ,double sigma); + template + static void itkDifferenceOfGaussianFilter(TImageType * image, mitk::Image::Pointer & smoothed, double sigma1, double sigma2); + template static void itkProbabilityMap(const TImageType * sourceImage, double mean, double std_dev, mitk::Image::Pointer& resultImage); + template + static void itkHessianOfGaussianFilter(itk::Image* itkImage, double variance, std::vector &out); + template + static void itkLaplacianOfGaussianFilter(itk::Image* itkImage, double variance, mitk::Image::Pointer &output); + template + static void itkLocalHistograms(itk::Image* itkImage, std::vector &out, int size, int bins); }; } //namespace MITK #endif diff --git a/Modules/Classification/CLUtilities/src/mitkCLUtil.cpp b/Modules/Classification/CLUtilities/src/mitkCLUtil.cpp index 6f22880b1b..e4b864f633 100644 --- a/Modules/Classification/CLUtilities/src/mitkCLUtil.cpp +++ b/Modules/Classification/CLUtilities/src/mitkCLUtil.cpp @@ -1,482 +1,631 @@ #ifndef _mitkCLUtil_HXX #define _mitkCLUtil_HXX #include #include #include #include // itk includes #include #include +#include "itkHessianRecursiveGaussianImageFilter.h" +#include "itkUnaryFunctorImageFilter.h" +#include "vnl/algo/vnl_symmetric_eigensystem.h" +#include +#include + // Morphologic Operations #include #include #include #include #include #include #include #include // Image Filter #include +#include void mitk::CLUtil::ProbabilityMap(const mitk::Image::Pointer & image , double mean, double stddev, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_3(image, mitk::CLUtil::itkProbabilityMap, 3, mean, stddev, outimage); } void mitk::CLUtil::ErodeGrayscale(mitk::Image::Pointer & image , unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_3(image, mitk::CLUtil::itkErodeGrayscale, 3, outimage, radius, d); } void mitk::CLUtil::DilateGrayscale(mitk::Image::Pointer & image, unsigned int radius, mitk::CLUtil::MorphologicalDimensions d, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_3(image, mitk::CLUtil::itkDilateGrayscale, 3, outimage, radius, d); } void mitk::CLUtil::FillHoleGrayscale(mitk::Image::Pointer & image, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_1(image, mitk::CLUtil::itkFillHoleGrayscale, 3, outimage); } void mitk::CLUtil::InsertLabel(mitk::Image::Pointer & image, mitk::Image::Pointer & maskImage, unsigned int label) { AccessByItk_2(image, mitk::CLUtil::itkInsertLabel, maskImage, label); } void mitk::CLUtil::GrabLabel(mitk::Image::Pointer & image, mitk::Image::Pointer & outimage, unsigned int label) { AccessFixedDimensionByItk_2(image, mitk::CLUtil::itkGrabLabel, 3, outimage, label); } void mitk::CLUtil::ConnectedComponentsImage(mitk::Image::Pointer & image, mitk::Image::Pointer& mask, mitk::Image::Pointer &outimage, unsigned int& num_components) { AccessFixedDimensionByItk_3(image, mitk::CLUtil::itkConnectedComponentsImage,3, mask, outimage, num_components); } void mitk::CLUtil::MergeLabels(mitk::Image::Pointer & img, const std::map & map) { AccessByItk_1(img, mitk::CLUtil::itkMergeLabels, map); } void mitk::CLUtil::CountVoxel(mitk::Image::Pointer image, std::map & map) { AccessByItk_1(image, mitk::CLUtil::itkCountVoxel, map); } void mitk::CLUtil::CountVoxel(mitk::Image::Pointer image, unsigned int label, unsigned int & count) { AccessByItk_2(image, mitk::CLUtil::itkCountVoxel, label, count); } void mitk::CLUtil::CountVoxel(mitk::Image::Pointer image, unsigned int & count) { AccessByItk_1(image, mitk::CLUtil::itkCountVoxel, count); } void mitk::CLUtil::CreateCheckerboardMask(mitk::Image::Pointer image, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_1(image, mitk::CLUtil::itkCreateCheckerboardMask,3, outimage); } void mitk::CLUtil::LogicalAndImages(const mitk::Image::Pointer & image1, const mitk::Image::Pointer & image2, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_2(image1,itkLogicalAndImages, 3, image2, outimage); } void mitk::CLUtil::InterpolateCheckerboardPrediction(mitk::Image::Pointer checkerboard_prediction, mitk::Image::Pointer & checkerboard_mask, mitk::Image::Pointer & outimage) { AccessFixedDimensionByItk_2(checkerboard_prediction, mitk::CLUtil::itkInterpolateCheckerboardPrediction,3, checkerboard_mask, outimage); } void mitk::CLUtil::GaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed ,double sigma) { AccessFixedDimensionByItk_2(image, mitk::CLUtil::itkGaussianFilter,3, smoothed, sigma); } +void mitk::CLUtil::DifferenceOfGaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed, double sigma1, double sigma2) +{ + AccessFixedDimensionByItk_3(image, mitk::CLUtil::itkDifferenceOfGaussianFilter, 3, smoothed, sigma1, sigma2); +} + +void mitk::CLUtil::LaplacianOfGaussianFilter(mitk::Image::Pointer image, mitk::Image::Pointer & smoothed, double sigma1) +{ + AccessByItk_2(image, mitk::CLUtil::itkLaplacianOfGaussianFilter, sigma1, smoothed); +} + +void mitk::CLUtil::HessianOfGaussianFilter(mitk::Image::Pointer image, std::vector &out, double sigma) +{ + AccessByItk_2(image, mitk::CLUtil::itkHessianOfGaussianFilter, sigma, out); +} + +void mitk::CLUtil::LocalHistogram(mitk::Image::Pointer image, std::vector &out, int Bins, int NeighbourhoodSize) +{ + AccessByItk_3(image, mitk::CLUtil::itkLocalHistograms, out, NeighbourhoodSize, Bins); +} + + void mitk::CLUtil::DilateBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int factor , MorphologicalDimensions d) { AccessFixedDimensionByItk_3(sourceImage, mitk::CLUtil::itkDilateBinary, 3, resultImage, factor, d); } void mitk::CLUtil::ErodeBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int factor, MorphologicalDimensions d) { AccessFixedDimensionByItk_3(sourceImage, mitk::CLUtil::itkErodeBinary, 3, resultImage, factor, d); } void mitk::CLUtil::ClosingBinary(mitk::Image::Pointer & sourceImage, mitk::Image::Pointer& resultImage, int factor, MorphologicalDimensions d) { AccessFixedDimensionByItk_3(sourceImage, mitk::CLUtil::itkClosingBinary, 3, resultImage, factor, d); } template void mitk::CLUtil::itkProbabilityMap(const TImageType * sourceImage, double mean, double std_dev, mitk::Image::Pointer& resultImage) { itk::Image::Pointer itk_img = itk::Image::New(); itk_img->SetRegions(sourceImage->GetLargestPossibleRegion()); itk_img->SetOrigin(sourceImage->GetOrigin()); itk_img->SetSpacing(sourceImage->GetSpacing()); itk_img->SetDirection(sourceImage->GetDirection()); itk_img->Allocate(); itk::ImageRegionConstIterator it(sourceImage,sourceImage->GetLargestPossibleRegion()); itk::ImageRegionIterator > outit(itk_img,itk_img->GetLargestPossibleRegion()); while(!it.IsAtEnd()) { double x = it.Value(); double prob = (1.0/(std_dev*std::sqrt(2.0*M_PI))) * std::exp(-(((x-mean)*(x-mean))/(2.0*std_dev*std_dev))); outit.Set(prob); ++it; ++outit; } mitk::CastToMitkImage(itk_img, resultImage); } template< typename TImageType > void mitk::CLUtil::itkInterpolateCheckerboardPrediction(TImageType * checkerboard_prediction, Image::Pointer &checkerboard_mask, mitk::Image::Pointer & outimage) { typename TImageType::Pointer itk_checkerboard_mask; mitk::CastToItkImage(checkerboard_mask,itk_checkerboard_mask); typename TImageType::Pointer itk_outimage = TImageType::New(); itk_outimage->SetRegions(checkerboard_prediction->GetLargestPossibleRegion()); itk_outimage->SetDirection(checkerboard_prediction->GetDirection()); itk_outimage->SetOrigin(checkerboard_prediction->GetOrigin()); itk_outimage->SetSpacing(checkerboard_prediction->GetSpacing()); itk_outimage->Allocate(); itk_outimage->FillBuffer(0); //typedef typename itk::ShapedNeighborhoodIterator::SizeType SizeType; typedef itk::Size<3> SizeType; SizeType size; size.Fill(1); itk::ShapedNeighborhoodIterator iit(size,checkerboard_prediction,checkerboard_prediction->GetLargestPossibleRegion()); itk::ShapedNeighborhoodIterator mit(size,itk_checkerboard_mask,itk_checkerboard_mask->GetLargestPossibleRegion()); itk::ImageRegionIterator oit(itk_outimage,itk_outimage->GetLargestPossibleRegion()); typedef typename itk::ShapedNeighborhoodIterator::OffsetType OffsetType; OffsetType offset; offset.Fill(0); offset[0] = 1; // {1,0,0} iit.ActivateOffset(offset); mit.ActivateOffset(offset); offset[0] = -1; // {-1,0,0} iit.ActivateOffset(offset); mit.ActivateOffset(offset); offset[0] = 0; offset[1] = 1; //{0,1,0} iit.ActivateOffset(offset); mit.ActivateOffset(offset); offset[1] = -1; //{0,-1,0} iit.ActivateOffset(offset); mit.ActivateOffset(offset); // iit.ActivateOffset({{0,0,1}}); // iit.ActivateOffset({{0,0,-1}}); // mit.ActivateOffset({{0,0,1}}); // mit.ActivateOffset({{0,0,-1}}); while(!iit.IsAtEnd()) { if(mit.GetCenterPixel() == 0) { typename TImageType::PixelType mean = 0; for (auto i = iit.Begin(); ! i.IsAtEnd(); i++) { mean += i.Get(); } //std::sort(list.begin(),list.end(),[](const typename TImageType::PixelType x,const typename TImageType::PixelType y){return x<=y;}); oit.Set((mean+0.5)/6.0); } else { oit.Set(iit.GetCenterPixel()); } ++iit; ++mit; ++oit; } mitk::CastToMitkImage(itk_outimage,outimage); } template< typename TImageType > void mitk::CLUtil::itkCreateCheckerboardMask(TImageType * image, mitk::Image::Pointer & outimage) { typename TImageType::Pointer zeroimg = TImageType::New(); zeroimg->SetRegions(image->GetLargestPossibleRegion()); zeroimg->SetDirection(image->GetDirection()); zeroimg->SetOrigin(image->GetOrigin()); zeroimg->SetSpacing(image->GetSpacing()); zeroimg->Allocate(); zeroimg->FillBuffer(0); typedef itk::CheckerBoardImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput1(image); filter->SetInput2(zeroimg); typename FilterType::PatternArrayType pattern; pattern.SetElement(0,(image->GetLargestPossibleRegion().GetSize()[0])); pattern.SetElement(1,(image->GetLargestPossibleRegion().GetSize()[1])); pattern.SetElement(2,(image->GetLargestPossibleRegion().GetSize()[2])); filter->SetCheckerPattern(pattern); filter->Update(); mitk::CastToMitkImage(filter->GetOutput(), outimage); } template void mitk::CLUtil::itkSumVoxelForLabel(TImageType* image, const mitk::Image::Pointer & source , typename TImageType::PixelType label, double & val ) { itk::Image::Pointer itk_source; mitk::CastToItkImage(source,itk_source); itk::ImageRegionConstIterator inputIter(image, image->GetLargestPossibleRegion()); itk::ImageRegionConstIterator< itk::Image > sourceIter(itk_source, itk_source->GetLargestPossibleRegion()); while(!inputIter.IsAtEnd()) { if(inputIter.Value() == label) val += sourceIter.Value(); ++inputIter; ++sourceIter; } } template void mitk::CLUtil::itkSqSumVoxelForLabel(TImageType* image, const mitk::Image::Pointer & source, typename TImageType::PixelType label, double & val ) { itk::Image::Pointer itk_source; mitk::CastToItkImage(source,itk_source); itk::ImageRegionConstIterator inputIter(image, image->GetLargestPossibleRegion()); itk::ImageRegionConstIterator< itk::Image > sourceIter(itk_source, itk_source->GetLargestPossibleRegion()); while(!inputIter.IsAtEnd()) { if(inputIter.Value() == label) val += sourceIter.Value() * sourceIter.Value(); ++inputIter; ++sourceIter; } } template void mitk::CLUtil::itkFitStructuringElement(TStructuringElement & se, MorphologicalDimensions d, int factor) { typename TStructuringElement::SizeType size; size.Fill(factor); switch(d) { case(All): case(Axial): size.SetElement(2,0); break; case(Sagital): size.SetElement(0,0); break; case(Coronal): size.SetElement(1,0); break; } se.SetRadius(size); se.CreateStructuringElement(); } template void mitk::CLUtil::itkClosingBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int factor, MorphologicalDimensions d) { typedef itk::BinaryBallStructuringElement BallType; typedef itk::BinaryMorphologicalClosingImageFilter FilterType; BallType strElem; itkFitStructuringElement(strElem,d,factor); typename FilterType::Pointer erodeFilter = FilterType::New(); erodeFilter->SetKernel(strElem); erodeFilter->SetInput(sourceImage); erodeFilter->SetForegroundValue(1); erodeFilter->Update(); mitk::CastToMitkImage(erodeFilter->GetOutput(), resultImage); } template void mitk::CLUtil::itkDilateBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int factor, MorphologicalDimensions d) { typedef itk::BinaryBallStructuringElement BallType; typedef typename itk::BinaryDilateImageFilter BallDilateFilterType; BallType strElem; itkFitStructuringElement(strElem,d,factor); typename BallDilateFilterType::Pointer erodeFilter = BallDilateFilterType::New(); erodeFilter->SetKernel(strElem); erodeFilter->SetInput(sourceImage); erodeFilter->SetDilateValue(1); erodeFilter->Update(); mitk::CastToMitkImage(erodeFilter->GetOutput(), resultImage); } template void mitk::CLUtil::itkErodeBinary(TImageType * sourceImage, mitk::Image::Pointer& resultImage, int factor, MorphologicalDimensions d) { typedef itk::BinaryBallStructuringElement BallType; typedef typename itk::BinaryErodeImageFilter BallErodeFilterType; BallType strElem; itkFitStructuringElement(strElem,d,factor); typename BallErodeFilterType::Pointer erodeFilter = BallErodeFilterType::New(); erodeFilter->SetKernel(strElem); erodeFilter->SetInput(sourceImage); erodeFilter->SetErodeValue(1); // erodeFilter->UpdateLargestPossibleRegion(); erodeFilter->Update(); mitk::CastToMitkImage(erodeFilter->GetOutput(), resultImage); } /// /// \brief itkFillHolesBinary /// \param sourceImage /// \param resultImage /// template void mitk::CLUtil::itkFillHolesBinary(itk::Image* sourceImage, mitk::Image::Pointer& resultImage) { typedef itk::Image ImageType; typedef typename itk::BinaryFillholeImageFilter FillHoleFilterType; typename FillHoleFilterType::Pointer fillHoleFilter = FillHoleFilterType::New(); fillHoleFilter->SetInput(sourceImage); fillHoleFilter->SetForegroundValue(1); fillHoleFilter->Update(); mitk::CastToMitkImage(fillHoleFilter->GetOutput(), resultImage); } /// /// \brief itkLogicalAndImages /// \param image1 keep the values of image 1 /// \param image2 /// template void mitk::CLUtil::itkLogicalAndImages(const TImageType * image1, const mitk::Image::Pointer & image2, mitk::Image::Pointer & outimage) { typename TImageType::Pointer itk_outimage = TImageType::New(); itk_outimage->SetRegions(image1->GetLargestPossibleRegion()); itk_outimage->SetDirection(image1->GetDirection()); itk_outimage->SetOrigin(image1->GetOrigin()); itk_outimage->SetSpacing(image1->GetSpacing()); itk_outimage->Allocate(); itk_outimage->FillBuffer(0); typename TImageType::Pointer itk_image2; mitk::CastToItkImage(image2,itk_image2); itk::ImageRegionConstIterator it1(image1, image1->GetLargestPossibleRegion()); itk::ImageRegionConstIterator it2(itk_image2, itk_image2->GetLargestPossibleRegion()); itk::ImageRegionIterator oit(itk_outimage,itk_outimage->GetLargestPossibleRegion()); while(!it1.IsAtEnd()) { if(it1.Value() == 0 || it2.Value() == 0) { oit.Set(0); }else oit.Set(it1.Value()); ++it1; ++it2; ++oit; } mitk::CastToMitkImage(itk_outimage, outimage); } /// /// \brief GaussianFilter /// \param image /// \param smoothed /// \param sigma /// template void mitk::CLUtil::itkGaussianFilter(TImageType * image, mitk::Image::Pointer & smoothed ,double sigma) { typedef itk::DiscreteGaussianImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput(image); filter->SetVariance(sigma); filter->Update(); mitk::CastToMitkImage(filter->GetOutput(),smoothed); } +template +void mitk::CLUtil::itkDifferenceOfGaussianFilter(TImageType * image, mitk::Image::Pointer & smoothed, double sigma1, double sigma2) +{ + typedef itk::DiscreteGaussianImageFilter FilterType; + typedef itk::SubtractImageFilter SubtractFilterType; + typename FilterType::Pointer filter1 = FilterType::New(); + typename FilterType::Pointer filter2 = FilterType::New(); + typename SubtractFilterType::Pointer subFilter = SubtractFilterType::New(); + filter1->SetInput(image); + filter1->SetVariance(sigma1); + filter1->Update(); + filter2->SetInput(image); + filter2->SetVariance(sigma2); + filter2->Update(); + subFilter->SetInput1(filter1->GetOutput()); + subFilter->SetInput2(filter2->GetOutput()); + subFilter->Update(); + + mitk::CastToMitkImage(subFilter->GetOutput(), smoothed); +} + + +template +void mitk::CLUtil::itkLaplacianOfGaussianFilter(itk::Image* itkImage, double variance, mitk::Image::Pointer &output) +{ + typedef itk::Image ImageType; + typedef itk::DiscreteGaussianImageFilter< ImageType, ImageType > GaussFilterType; + typedef itk::LaplacianRecursiveGaussianImageFilter LaplacianFilter; + + typename GaussFilterType::Pointer gaussianFilter = GaussFilterType::New(); + gaussianFilter->SetInput(itkImage); + gaussianFilter->SetVariance(variance); + gaussianFilter->Update(); + typename LaplacianFilter::Pointer laplaceFilter = LaplacianFilter::New(); + laplaceFilter->SetInput(gaussianFilter->GetOutput()); + laplaceFilter->Update(); + mitk::CastToMitkImage(laplaceFilter->GetOutput(), output); +} + +namespace Functor +{ + template + class MatrixFirstEigenvalue + { + public: + MatrixFirstEigenvalue() {} + virtual ~MatrixFirstEigenvalue() {} + + int order; + + inline TOutput operator ()(const TInput& input) + { + double a, b, c; + if (input[0] < 0.01 && input[1] < 0.01 &&input[2] < 0.01 &&input[3] < 0.01 &&input[4] < 0.01 &&input[5] < 0.01) + return 0; + vnl_symmetric_eigensystem_compute_eigenvals(input[0], input[1], input[2], input[3], input[4], input[5], a, b, c); + switch (order) + { + case 0: return a; + case 1: return b; + case 2: return c; + default: return a; + } + } + bool operator !=(const MatrixFirstEigenvalue) const + { + return false; + } + bool operator ==(const MatrixFirstEigenvalue& other) const + { + return !(*this != other); + } + }; +} + +template +void mitk::CLUtil::itkHessianOfGaussianFilter(itk::Image* itkImage, double variance, std::vector &out) +{ + typedef itk::Image ImageType; + typedef itk::Image FloatImageType; + typedef itk::HessianRecursiveGaussianImageFilter HessianFilterType; + typedef typename HessianFilterType::OutputImageType VectorImageType; + typedef Functor::MatrixFirstEigenvalue DeterminantFunctorType; + typedef itk::UnaryFunctorImageFilter DetFilterType; + + typename HessianFilterType::Pointer hessianFilter = HessianFilterType::New(); + hessianFilter->SetInput(itkImage); + hessianFilter->SetSigma(std::sqrt(variance)); + for (int i = 0; i < VImageDimension; ++i) + { + mitk::Image::Pointer tmpImage = mitk::Image::New(); + typename DetFilterType::Pointer detFilter = DetFilterType::New(); + detFilter->SetInput(hessianFilter->GetOutput()); + detFilter->GetFunctor().order = i; + detFilter->Update(); + mitk::CastToMitkImage(detFilter->GetOutput(), tmpImage); + out.push_back(tmpImage); + } +} + +template +void mitk::CLUtil::itkLocalHistograms(itk::Image* itkImage, std::vector &out, int size, int bins) +{ + typedef itk::Image ImageType; + typedef itk::Image FloatImageType; + typedef itk::MultiHistogramFilter MultiHistogramType; + + typename MultiHistogramType::Pointer filter = MultiHistogramType::New(); + filter->SetInput(itkImage); + filter->SetUseImageIntensityRange(true); + filter->SetSize(size); + filter->SetBins(bins); + filter->Update(); + for (int i = 0; i < bins; ++i) + { + mitk::Image::Pointer img = mitk::Image::New(); + mitk::CastToMitkImage(filter->GetOutput(i), img); + out.push_back(img); + } +} + template void mitk::CLUtil::itkErodeGrayscale(TImageType * image, mitk::Image::Pointer & outimage , unsigned int radius, mitk::CLUtil::MorphologicalDimensions d) { typedef itk::BinaryBallStructuringElement StructureElementType; typedef itk::GrayscaleErodeImageFilter FilterType; StructureElementType ball; itkFitStructuringElement(ball,d, radius); typename FilterType::Pointer filter = FilterType::New(); filter->SetKernel(ball); filter->SetInput(image); filter->Update(); mitk::CastToMitkImage(filter->GetOutput(),outimage); } template void mitk::CLUtil::itkDilateGrayscale(TImageType * image, mitk::Image::Pointer & outimage , unsigned int radius, mitk::CLUtil::MorphologicalDimensions d) { typedef itk::BinaryBallStructuringElement StructureElementType; typedef itk::GrayscaleDilateImageFilter FilterType; StructureElementType ball; itkFitStructuringElement(ball,d, radius); typename FilterType::Pointer filter = FilterType::New(); filter->SetKernel(ball); filter->SetInput(image); filter->Update(); mitk::CastToMitkImage(filter->GetOutput(),outimage); } template void mitk::CLUtil::itkFillHoleGrayscale(TImageType * image, mitk::Image::Pointer & outimage) { typedef itk::GrayscaleFillholeImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); filter->SetInput(image); filter->Update(); mitk::CastToMitkImage(filter->GetOutput(),outimage); } #endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 6365beaa12..382214a679 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,101 +1,102 @@ # Plug-ins must be ordered according to their dependencies set(MITK_PLUGINS org.blueberry.core.runtime:ON org.blueberry.core.expressions:OFF org.blueberry.core.commands:OFF org.blueberry.core.jobs:OFF org.blueberry.ui.qt:OFF org.blueberry.ui.qt.help:ON org.blueberry.ui.qt.log:ON org.blueberry.ui.qt.objectinspector:OFF #org.blueberry.test:ON #org.blueberry.uitest:ON #Testing/org.blueberry.core.runtime.tests:ON #Testing/org.blueberry.osgi.tests:ON org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.dicominspector:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.diffusionimaging.connectomics:OFF org.mitk.gui.qt.diffusionimaging.denoising:OFF org.mitk.gui.qt.diffusionimaging.fiberfox:OFF org.mitk.gui.qt.diffusionimaging.fiberprocessing:OFF org.mitk.gui.qt.diffusionimaging.ivim:OFF org.mitk.gui.qt.diffusionimaging.odfpeaks:OFF org.mitk.gui.qt.diffusionimaging.partialvolume:OFF org.mitk.gui.qt.diffusionimaging.preprocessing:OFF org.mitk.gui.qt.diffusionimaging.reconstruction:OFF org.mitk.gui.qt.diffusionimaging.registration:OFF org.mitk.gui.qt.diffusionimaging.tbss:OFF org.mitk.gui.qt.diffusionimaging.tractography:OFF org.mitk.gui.qt.dosevisualization:OFF org.mitk.gui.qt.geometrytools:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.lasercontrol:OFF org.mitk.gui.qt.openigtlink:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.viewnavigator:OFF org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.pointsetinteractionmultispectrum:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.aicpregistration:OFF org.mitk.gui.qt.renderwindowmanager:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.tubegraph:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF org.mitk.gui.qt.eventrecorder:OFF org.mitk.gui.qt.xnat:OFF org.mitk.gui.qt.igt.app.echotrack:OFF org.mitk.gui.qt.spectrocamrecorder:OFF org.mitk.gui.qt.classificationsegmentation:OFF org.mitk.gui.qt.overlaymanager:OFF org.mitk.gui.qt.igt.app.hummelprotocolmeasurements:OFF org.mitk.gui.qt.multilabelsegmentation:OFF org.mitk.matchpoint.core.helper:OFF org.mitk.gui.qt.matchpoint.algorithm.browser:OFF org.mitk.gui.qt.matchpoint.algorithm.control:OFF org.mitk.gui.qt.matchpoint.algorithm.batch:OFF org.mitk.gui.qt.matchpoint.mapper:OFF org.mitk.gui.qt.matchpoint.framereg:OFF org.mitk.gui.qt.matchpoint.visualizer:OFF org.mitk.gui.qt.matchpoint.evaluator:OFF org.mitk.gui.qt.matchpoint.manipulator:OFF org.mitk.gui.qt.photoacoustics.pausviewer:OFF + org.mitk.gui.qt.preprocessing.resampling:OFF org.mitk.gui.qt.photoacoustics.imageprocessing:OFF org.mitk.gui.qt.cest:OFF ) diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/files.cmake b/Plugins/org.mitk.gui.qt.classificationsegmentation/files.cmake index bc0dcc0253..d058df59d8 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/files.cmake +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/files.cmake @@ -1,43 +1,46 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_classificationsegmentation_Activator.cpp ClassificationSegmentation.cpp + ClassificationRegionGrow.cpp ) set(UI_FILES src/internal/ClassificationSegmentationControls.ui + src/internal/ClassificationRegionGrowControls.ui ) set(MOC_H_FILES src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h src/internal/ClassificationSegmentation.h + src/internal/ClassificationRegionGrow.h ) # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench set(CACHED_RESOURCE_FILES resources/icon_32.png resources/icon.png plugin.xml ) # list of Qt .qrc files which contain additional resources # specific to this plugin set(QRC_FILES resources/ClassificationSegmentation.qrc ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/plugin.xml b/Plugins/org.mitk.gui.qt.classificationsegmentation/plugin.xml index 52ee35adc7..0e79fbf0ac 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/plugin.xml +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/plugin.xml @@ -1,11 +1,15 @@ + diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.cpp b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.cpp new file mode 100644 index 0000000000..3aa438c40a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.cpp @@ -0,0 +1,645 @@ +/*=================================================================== + +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. + +===================================================================*/ +// STD +#include + + +// Blueberry +#include +#include + +// Qmitk +#include "ClassificationRegionGrow.h" + +// Qt +#include +#include +#include + +//mitk image +#include +#include +#include +#include +#include +#include +#include "mitkVigraRandomForestClassifier.h" +#include "mitkCLUtil.h" +#include "qboxlayout.h" +#include + +#include "Eigen/Dense" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//#include +#include "mitkLabelSetImage.h" +#include + +#include +#include + +#include +#include +#include +#include +#include +const std::string ClassificationRegionGrow::VIEW_ID = "org.mitk.views.ClassificationRegionGrow"; + +void ClassificationRegionGrow::SetFocus() +{ + // m_Controls.buttonPerformImageProcessing->setFocus(); +} + +void ClassificationRegionGrow::CreateQtPartControl( QWidget *parent ) +{ + // create GUI widgets from the Qt Designer's .ui file + m_Controls.setupUi( parent ); + m_CalculateFeatures = true; + m_BlockManualSegmentation = false; + m_BlockPostProcessing = false; + + m_Controls.groupLearningParameter->setVisible(false); + m_Controls.groupFeatureSelection->setVisible(false); + + QmitkDataStorageComboBox * cb_inputimage = new QmitkDataStorageComboBox(this->GetDataStorage(), mitk::TNodePredicateDataType::New()); + QmitkDataStorageComboBox * cb_maskimage= new QmitkDataStorageComboBox(this->GetDataStorage(),mitk::TNodePredicateDataType::New()); + QmitkDataStorageComboBox * cb_baseimage = new QmitkDataStorageComboBox(this->GetDataStorage(), mitk::TNodePredicateDataType::New()); + + m_Controls.m_InputImageLayout->addWidget(cb_inputimage); + m_Controls.m_MaskImageLayout->addWidget(cb_maskimage); + m_Controls.StartingPointLayout->addWidget(cb_baseimage); + m_Controls.addInputButton->setIcon(QIcon::fromTheme("list-add")); + m_Controls.removeInputButton->setIcon(QIcon::fromTheme("edit-delete")); + + connect( cb_inputimage, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnInitializeSession(const mitk::DataNode*))); + connect( cb_maskimage, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnInitializeSession(const mitk::DataNode*))); + connect(m_Controls.SelectAdvancedParameter, SIGNAL(toggled(bool)), m_Controls.groupLearningParameter, SLOT(setVisible(bool))); + connect(m_Controls.SelectAdvancedParameter, SIGNAL(toggled(bool)), m_Controls.groupFeatureSelection, SLOT(setVisible(bool))); + connect(m_Controls.SelectSimpleParameters, SIGNAL(toggled(bool)), m_Controls.parameterWidget, SLOT(setVisible(bool))); + connect(m_Controls.m_DoAutomaticSecmentation, SIGNAL( clicked()), this, SLOT(DoAutomSegmentation())); + connect(m_Controls.removeInputButton, SIGNAL(clicked()), this, SLOT(RemoveItemFromLabelList())); + connect(m_Controls.addInputButton, SIGNAL(clicked()), this, SLOT(AddInputField())); + + connect(m_Controls.UseIntensity, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.Gauss1, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.Gauss2, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.Gauss3, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.Gauss4, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.Gauss5, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.DoG1, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.DoG2, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.DoG3, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.DoG4, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.DoG5, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LoG1, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LoG2, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LoG3, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LoG4, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LoG5, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.HoG1, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.HoG2, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.HoG3, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.HoG4, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.HoG5, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LH1, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LH2, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LH3, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); + connect(m_Controls.LH4, SIGNAL(toggled(bool)), this, SLOT(OnFeatureSettingsChanged())); +} + +void ClassificationRegionGrow::AddInputField() +{ + QmitkDataStorageComboBox * cb_inputimage = new QmitkDataStorageComboBox(this->GetDataStorage(), mitk::TNodePredicateDataType::New()); + //QPushButton * lockButton = new QPushButton(); + //lockButton->setText(""); + //lockButton->setMinimumWidth(40); + //lockButton->setCheckable(true); + //lockButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaStop)); + + QHBoxLayout *layout = new QHBoxLayout; + layout->addWidget(cb_inputimage,100); + //layout->addWidget(lockButton,1); + m_Controls.m_InputImageLayout->addLayout(layout); + connect(cb_inputimage, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnInitializeSession(const mitk::DataNode*))); +} + +void ClassificationRegionGrow::RemoveItemFromLabelList() +{ + auto numberOfElements = m_Controls.m_InputImageLayout->count(); + auto lastItem = m_Controls.m_InputImageLayout->itemAt(numberOfElements-1); + QHBoxLayout *layout = dynamic_cast(lastItem); + while (QLayoutItem* item = layout->takeAt(0)) + { + if (QWidget* widget = item->widget()) + widget->deleteLater(); + delete item; + } + m_Controls.m_InputImageLayout->removeItem(lastItem); + delete lastItem; + +} + +void ClassificationRegionGrow::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, + const QList& nodes ) +{ + // iterate all selected objects, adjust warning visibility + foreach( mitk::DataNode::Pointer node, nodes ) + { + if( node.IsNotNull() && dynamic_cast(node->GetData()) ) + { + return; + } + } +} + +void ClassificationRegionGrow::OnInitializeSession(const mitk::DataNode *) +{ + OnFeatureSettingsChanged(); +} + +void ClassificationRegionGrow::ProcessFeatureImages(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & brain_mask) +{ + typedef itk::Image DoubleImageType; + typedef itk::Image ShortImageType; + typedef itk::ConstNeighborhoodIterator NeighborhoodType; // Neighborhood iterator to access image + typedef itk::Functor::NeighborhoodFirstOrderStatistics FunctorType; + typedef itk::NeighborhoodFunctorImageFilter FOSFilerType; + typedef FOSFilerType::MaskImageType MaskImageType; + + double gaussValue = 2; + double hessianValue = 2; + double structureTensorInner = 1.8; + double structureTensorOuter = 2.4; + + // RAW + if (m_Controls.UseIntensity->isChecked()) { + m_FeatureImageVector.push_back(raw_image); + } + + // GAUSS + if (m_Controls.Gauss1->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::GaussianFilter(raw_image, smoothed, 1); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.Gauss2->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::GaussianFilter(raw_image, smoothed, 2); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.Gauss3->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::GaussianFilter(raw_image, smoothed, 3); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.Gauss4->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::GaussianFilter(raw_image, smoothed, 4); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.Gauss5->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::GaussianFilter(raw_image, smoothed, 5); + m_FeatureImageVector.push_back(smoothed); + } + + // Difference of Gaussian + if (m_Controls.DoG1->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::DifferenceOfGaussianFilter(raw_image, smoothed, 1,0.8); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.DoG2->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::DifferenceOfGaussianFilter(raw_image, smoothed, 2, 1.8); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.DoG3->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::DifferenceOfGaussianFilter(raw_image, smoothed, 3, 2.6); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.DoG4->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::DifferenceOfGaussianFilter(raw_image, smoothed, 4, 3.4); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.DoG5->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::DifferenceOfGaussianFilter(raw_image, smoothed, 5, 4.3); + m_FeatureImageVector.push_back(smoothed); + } + + // Laplacian of Gaussian + if (m_Controls.LoG1->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::LaplacianOfGaussianFilter(raw_image, smoothed, 1); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.LoG2->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::LaplacianOfGaussianFilter(raw_image, smoothed, 2); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.LoG3->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::LaplacianOfGaussianFilter(raw_image, smoothed, 3); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.LoG4->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::LaplacianOfGaussianFilter(raw_image, smoothed, 4); + m_FeatureImageVector.push_back(smoothed); + } + if (m_Controls.LoG5->isChecked()) + { + mitk::Image::Pointer smoothed; + mitk::CLUtil::LaplacianOfGaussianFilter(raw_image, smoothed, 5); + m_FeatureImageVector.push_back(smoothed); + } + + // Hessian of Gaussian + if (m_Controls.HoG1->isChecked()) + { + mitk::CLUtil::HessianOfGaussianFilter(raw_image, m_FeatureImageVector, 1); + } + if (m_Controls.HoG2->isChecked()) + { + mitk::CLUtil::HessianOfGaussianFilter(raw_image, m_FeatureImageVector, 2); + } + if (m_Controls.HoG3->isChecked()) + { + mitk::CLUtil::HessianOfGaussianFilter(raw_image, m_FeatureImageVector, 3); + } + if (m_Controls.HoG4->isChecked()) + { + mitk::CLUtil::HessianOfGaussianFilter(raw_image, m_FeatureImageVector, 4); + } + if (m_Controls.HoG5->isChecked()) + { + mitk::CLUtil::HessianOfGaussianFilter(raw_image, m_FeatureImageVector, 5); + } + + // LocalHistogram + if (m_Controls.LH1->isChecked()) + { + mitk::CLUtil::LocalHistogram(raw_image, m_FeatureImageVector, 5,3); + } + if (m_Controls.LH2->isChecked()) + { + mitk::CLUtil::LocalHistogram(raw_image, m_FeatureImageVector, 5, 5); + } + if (m_Controls.LH3->isChecked()) + { + mitk::CLUtil::LocalHistogram(raw_image, m_FeatureImageVector, 10, 3); + } + if (m_Controls.LH4->isChecked()) + { + mitk::CLUtil::LocalHistogram(raw_image, m_FeatureImageVector, 10, 5); + } +} + +void ClassificationRegionGrow::OnFeatureSettingsChanged() +{ + MITK_INFO << "FeatureSettingsChanged"; + m_CalculateFeatures = true; +} + +void ClassificationRegionGrow::DoAutomSegmentation() +{ + MITK_INFO << "Start Automatic Segmentation ..."; + // Load Images from registration process + QmitkDataStorageComboBox * cb_image = dynamic_cast(m_Controls.m_InputImageLayout->itemAt(1)->widget()); + QmitkDataStorageComboBox * cb_maskimage = dynamic_cast(m_Controls.m_MaskImageLayout->itemAt(1)->widget()); + mitk::Image::Pointer raw_image; + mitk::Image::Pointer mask_image; + if ((cb_image != NULL) || (cb_maskimage != NULL)) + { + raw_image = dynamic_cast(cb_image->GetSelectedNode()->GetData()); + mask_image = dynamic_cast(cb_maskimage->GetSelectedNode()->GetData()); + } + else { + QMessageBox msgBox; + msgBox.setText("Please specify the images that shlould be used."); + msgBox.exec(); + return; + } + + if (raw_image.IsNull() || mask_image.IsNull()) + { + QMessageBox msgBox; + msgBox.setText("Error during processing the specified images."); + msgBox.exec(); + return; + } + + std::vector imageList; + imageList.push_back(raw_image); + for (int i = 2; i < m_Controls.m_InputImageLayout->count(); ++i) + { + QLayout* layout = dynamic_cast(m_Controls.m_InputImageLayout->itemAt(i)); + MITK_INFO << layout; + QmitkDataStorageComboBox * tmp_cb_image = dynamic_cast(layout->itemAt(0)->widget()); + MITK_INFO << tmp_cb_image; + if (tmp_cb_image) + { + mitk::Image::Pointer tmp_image = dynamic_cast(tmp_cb_image); + if (tmp_image.IsNotNull()) + { + MITK_INFO << "Adding Image..."; + imageList.push_back(tmp_image); + } + } + } + + MITK_INFO << "Start Feature Calculation ..."; + if(m_CalculateFeatures) + { + m_FeatureImageVector.clear(); + for (auto img : imageList) + { + ProcessFeatureImages(img, mask_image); + } + m_CalculateFeatures = false; + if (m_Controls.checkAddFeaturesToDataManager->isChecked()) + { + for (int i = 0; i < m_FeatureImageVector.size(); ++i) + { + auto newName = "Feature_" + std::to_string(i); + AddAsDataNode(m_FeatureImageVector[i].GetPointer(), newName); + } + } + } + + MITK_INFO << "Start Classifier Training ..."; + TrainClassifier(raw_image, mask_image); + + MITK_INFO << "Predict extended Segmentation ..."; + PredictSegmentation(raw_image, mask_image); +} + + +void ClassificationRegionGrow::TrainClassifier(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image) +{ + typedef itk::Image DoubleImageType; + typedef itk::Image ShortImageType; + typedef itk::ConstNeighborhoodIterator NeighborhoodType; // Neighborhood iterator to access image + typedef itk::Functor::NeighborhoodFirstOrderStatistics FunctorType; + typedef itk::NeighborhoodFunctorImageFilter FOSFilerType; + + DoubleImageType::Pointer input; + ShortImageType::Pointer mask; + mitk::CastToItkImage(raw_image, input); + mitk::CastToItkImage(mask_image, mask); + + int numberOfSegmentedVoxel = 0; + int numberOfFeatures = m_FeatureImageVector.size(); + + auto maskIter = itk::ImageRegionConstIteratorWithIndex(mask, mask->GetLargestPossibleRegion()); + m_SegmentedLocations.clear(); + m_SegmentedOrganLocations.clear(); + + MITK_INFO << "Count Segmentation Size ..."; + while ( ! maskIter.IsAtEnd()) + { + if (maskIter.Value() > 0) + { + m_SegmentedLocations.push_back(maskIter.GetIndex()); + numberOfSegmentedVoxel++; + if (maskIter.Value() > 1) + { + m_SegmentedOrganLocations.push_back(maskIter.GetIndex()); + } + } + ++maskIter; + } + MITK_INFO << "Sizes: " << numberOfSegmentedVoxel << " " << m_SegmentedOrganLocations.size(); + + Eigen::MatrixXi Y_train = mitk::CLUtil::Transform(mask_image, mask_image); + Eigen::MatrixXd X_train = Eigen::MatrixXd(numberOfSegmentedVoxel, numberOfFeatures); + unsigned int index = 0; + + MITK_INFO << "Convert Training Data to Eigen Matrix ..."; + for (const auto & image : m_FeatureImageVector) + { + X_train.col(index) = mitk::CLUtil::Transform(image, mask_image); + ++index; + } + + MITK_INFO << "Classifier Training ..."; + m_Classifier = mitk::VigraRandomForestClassifier::New(); + //this->m_Controls.Maximum + m_Classifier->SetTreeCount(m_Controls.NumberOfTrees->value()); + m_Classifier->SetSamplesPerTree(m_Controls.SamplesPerTree->value()); + m_Classifier->SetMinimumSplitNodeSize(m_Controls.MinimumSamplesPerNode->value()); + m_Classifier->SetMaximumTreeDepth(m_Controls.MaximumTreeDepth->value()); + m_Classifier->Train(X_train, Y_train); +} + +static void addNeighbours(std::stack > &stack, itk::Index<3> idx) +{ + idx[0] -= 1; + stack.push(idx); + idx[0] += 2; + stack.push(idx); + idx[0] -= 1; + idx[1] -= 1; + stack.push(idx); + idx[1] += 2; + stack.push(idx); + idx[1] -= 1; + idx[2] -= 1; + stack.push(idx); + idx[2] += 2; + stack.push(idx); +} + +void ClassificationRegionGrow::PredictSegmentation(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image) +{ + typedef itk::Image DoubleImageType; + typedef itk::Image ShortImageType; + + DoubleImageType::Pointer input; + ShortImageType::Pointer mask; + mitk::CastToItkImage(raw_image, input); + mitk::CastToItkImage(mask_image, mask); + + std::vector featureImages; + for (auto fimage : m_FeatureImageVector) + { + DoubleImageType::Pointer feature; + mitk::CastToItkImage(fimage, feature); + featureImages.push_back(feature); + } + + ShortImageType::Pointer usedLocation = ShortImageType::New(); + usedLocation->SetRegions(mask->GetLargestPossibleRegion()); + usedLocation->Allocate(); + usedLocation->FillBuffer(0); + + ShortImageType::Pointer resultSegmentation = ShortImageType::New(); + if (m_Controls.UpdateImage->isChecked()) { + QmitkDataStorageComboBox * cb_maskimage = dynamic_cast(m_Controls.StartingPointLayout->itemAt(2)->widget()); + mitk::Image::Pointer base_image = dynamic_cast(cb_maskimage->GetSelectedNode()->GetData()); + mitk::CastToItkImage(base_image, resultSegmentation); + } + else { + + resultSegmentation->SetRegions(mask->GetLargestPossibleRegion()); + resultSegmentation->Allocate(); + if (m_Controls.SegmentBackground->isChecked()) + { + resultSegmentation->FillBuffer(1); + } + else { + resultSegmentation->FillBuffer(0); + } + } + + // Fill list of Stacks + std::vector > > listOfStacks; + while (m_SegmentedOrganLocations.size() > 0) + { + auto currentLocation = m_SegmentedOrganLocations.back(); + m_SegmentedOrganLocations.pop_back(); + auto cValue = mask->GetPixel(currentLocation); + resultSegmentation->SetPixel(currentLocation, cValue); + usedLocation->SetPixel(currentLocation, 1000); + while (listOfStacks.size() < cValue+1) + { + listOfStacks.push_back(std::stack >()); + } + addNeighbours(listOfStacks[cValue],currentLocation); + } + + + int countPredicted = 0; + bool connectAllLabels = m_Controls.localGrowing->isChecked(); + //m_SegmentedOrganLocations.reserve(10000); + + Eigen::MatrixXd currentX = Eigen::MatrixXd(1, featureImages.size()); + vigra::MultiArrayView<2, double> X(vigra::Shape2(currentX.rows(), currentX.cols()), currentX.data()); + auto outLabel = Eigen::MatrixXi(currentX.rows(), 1); + vigra::MultiArrayView<2, int> Y(vigra::Shape2(currentX.rows(), 1), outLabel.data()); + for (int i = 2; i < listOfStacks.size(); ++i) + { + while (listOfStacks[i].size() > 0) + { + auto currentLocation = listOfStacks[i].top(); + listOfStacks[i].pop(); + if (!mask->GetLargestPossibleRegion().IsInside(currentLocation)) + { + continue; + } + if (usedLocation->GetPixel(currentLocation) > i) + { + continue; + } + usedLocation->SetPixel(currentLocation, i+1); + + + for (int f = 0; f < featureImages.size(); ++f) + { + currentX(0, f) = featureImages[f]->GetPixel(currentLocation); + } + + m_Classifier->GetRandomForest().predictLabels(X, Y); + ++countPredicted; + if ((Y(0, 0) == i) || + ((Y(0, 0) > 1) && (connectAllLabels))) + { + resultSegmentation->SetPixel(currentLocation, Y(0, 0)); + addNeighbours(listOfStacks[i], currentLocation); + } + } + } + MITK_INFO << "Number of Predictions: " << countPredicted; + + MITK_INFO << "Finished Segmentation..."; + mitk::Image::Pointer result; + mitk::CastToMitkImage(resultSegmentation, result); + result->SetOrigin(raw_image->GetGeometry()->GetOrigin()); + result->SetSpacing(raw_image->GetGeometry()->GetSpacing()); + mitk::LabelSetImage::Pointer labelResult = mitk::LabelSetImage::New(); + labelResult->InitializeByLabeledImage(result); + mitk::LabelSetImage::Pointer oldLabelSet = dynamic_cast(mask_image.GetPointer()); + labelResult->AddLabelSetToLayer(labelResult->GetActiveLayer(),oldLabelSet->GetLabelSet()); + MITK_INFO << "Passing Back..."; + AddAsDataNode(labelResult.GetPointer(), "ResultSegmentation"); +} + +mitk::DataNode::Pointer ClassificationRegionGrow::AddAsDataNode(const mitk::BaseData::Pointer & data_, const std::string & name ) +{ + mitk::DataNode::Pointer node = nullptr; + node = this->GetDataStorage()->GetNamedNode(name); + + if(node.IsNull()) + { + node = mitk::DataNode::New(); + node->SetData(data_); + node->SetName(name); + this->GetDataStorage()->Add(node); + }else{ + + if(dynamic_cast(node->GetData()) && dynamic_cast(data_.GetPointer())) + { + mitk::Image::Pointer target_image = dynamic_cast(node->GetData()); + mitk::Image::Pointer source_image = dynamic_cast(data_.GetPointer()); + mitk::ImageReadAccessor ra(source_image); + target_image->SetImportVolume(const_cast(ra.GetData())); + this->RequestRenderWindowUpdate(); + } + + if(dynamic_cast(node->GetData()) && dynamic_cast(data_.GetPointer())) + { + node->SetData(data_); + node->Modified(); + } + + } + + return node; +} diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h new file mode 100644 index 0000000000..4d8c917aae --- /dev/null +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h @@ -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. + +===================================================================*/ + +#ifndef ClassificationRegionGrow_h +#define ClassificationRegionGrow_h + +#include + +#include + +#include "ui_ClassificationRegionGrowControls.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "QmitkPointListViewWidget.h" +#include + +#include +/** +\brief ClassificationRegionGrow + +\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. + +\sa QmitkAbstractView +\ingroup ${plugin_target}_internal +*/ + + +//class QmitkPointListWidget; +class ctkSliderWidget; +class ClassificationRegionGrow : public QmitkAbstractView +{ + // this is needed for all Qt objects that should have a Qt meta-object + // (everything that derives from QObject and wants to have signal/slots) + Q_OBJECT + +public: + + static const std::string VIEW_ID; + + bool m_CalculateFeatures; + + std::vector m_FeatureImageVector; + std::vector m_ResultImageVector; + + bool m_BlockManualSegmentation; + QFutureWatcher> m_ManualSegmentationFutureWatcher; + + bool m_BlockPostProcessing; + QFutureWatcher> m_PostProcessingFutureWatcher; + + public slots: + + /// \brief Called when the user clicks the GUI button + void DoAutomSegmentation(); + void AddInputField(); + + void RemoveItemFromLabelList(); + + void OnFeatureSettingsChanged(); + void OnInitializeSession(const mitk::DataNode*); + +protected: + std::vector > m_SegmentedLocations; + std::vector > m_SegmentedOrganLocations; + + + + typedef float MeasurementType; + typedef itk::Statistics::Histogram< MeasurementType, + itk::Statistics::DenseFrequencyContainer2 > HistogramType; + + + virtual void CreateQtPartControl(QWidget *parent) override; + virtual void SetFocus() override; + + mitk::DataNode::Pointer AddAsDataNode(const mitk::BaseData::Pointer & data_, const std::string & name ); + + void ProcessFeatureImages(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); + void TrainClassifier(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); + void PredictSegmentation(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); + + /// \brief called by QmitkFunctionality when DataManager's selection has changed + virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, + const QList& nodes ) override; + + Ui::ClassificationRegionGrowControls m_Controls; + + mitk::VigraRandomForestClassifier::Pointer m_Classifier; +}; + +#endif // ClassificationRegionGrow_h diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrowControls.ui b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrowControls.ui new file mode 100644 index 0000000000..ad002f99b0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrowControls.ui @@ -0,0 +1,593 @@ + + + ClassificationRegionGrowControls + + + + 0 + 0 + 352 + 979 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + + 17 + 75 + true + false + false + PreferAntialias + true + + + + Classifier Region Growing + + + + + + + + + + true + + + + Basic Image + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + false + + + false + + + + + + + + + + + + + + + + + + + true + + + + Segmentation Image + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 0 + 64 + + + + + Segoe UI + 14 + 75 + true + + + + Update Segmentation + + + + :/ClassificationSegmentation/button_process_2.png:/ClassificationSegmentation/button_process_2.png + + + + 32 + 32 + + + + Ctrl+A + + + + + + + Parameters + + + true + + + + + + + + + Segment Background (First Label) + + + + + + + Connectness for all labels + + + + + + + + + + + + + + + + Use existing segmentation as starting point + + + + + + + + + + + + + + + Advanced Parameter + + + true + + + false + + + + + + Learning Parameters + + + + + + Samples per Tree: + + + + + + + 0.010000000000000 + + + 1.000000000000000 + + + 0.100000000000000 + + + 0.660000000000000 + + + + + + + Number of Trees: + + + + + + + 1 + + + 2000 + + + 10 + + + + + + + Minimum Samples per Node: + + + + + + + 1 + + + 200000 + + + 5 + + + + + + + Maximum Tree depth: + + + + + + + 1 + + + 2000000 + + + 100 + + + + + + + + + + Feature Selection + + + false + + + + + + 4 + + + + + + + 3 + + + + + + + Laplacian of Gauss: + + + + + + + 5 + + + + + + + Intensity Value: + + + + + + + 4 + + + + + + + ( Neigh. Size / Bins) + + + + + + + 3 + + + + + + + 2 + + + + + + + Add Feature Images to DataManager + + + + + + + Diff. of Gauss: + + + + + + + 4 + + + + + + + 1 + + + + + + + 1 + + + + + + + 5 + + + + + + + 3 + + + + + + + + + + true + + + + + + + 5 + + + + + + + 1 + + + + + + + Hessian of Gaussian: + + + + + + + 2 + + + + + + + Local Histogram + + + + + + + 2 + + + true + + + + + + + Gaussian smoothed: + + + + + + + 1 + + + + + + + 2 + + + + + + + 4 + + + + + + + 3 + + + + + + + 5 + + + + + + + 3/5 + + + + + + + 5/5 + + + + + + + 3/10 + + + + + + + 5/10 + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.cpp similarity index 60% copy from Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp copy to Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.cpp index 3fb6fb829a..fa6ce8555f 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.cpp @@ -1,33 +1,33 @@ /*=================================================================== 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 "org_mitk_gui_qt_classificationsegmentation_Activator.h" -#include "ClassificationSegmentation.h" +#include "org_mitk_gui_qt_classificationregiongrow_Activator.h" +#include "ClassificationRegionGrow.h" namespace mitk { -void org_mitk_gui_qt_classificationsegmentation_Activator::start(ctkPluginContext* context) +void org_mitk_gui_qt_classificationregiongrow_Activator::start(ctkPluginContext* context) { - BERRY_REGISTER_EXTENSION_CLASS(ClassificationSegmentation, context) + BERRY_REGISTER_EXTENSION_CLASS(ClassificationRegionGrow, context) } -void org_mitk_gui_qt_classificationsegmentation_Activator::stop(ctkPluginContext* context) +void org_mitk_gui_qt_classificationregiongrow_Activator::stop(ctkPluginContext* context) { Q_UNUSED(context) } } diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.h similarity index 66% copy from Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h copy to Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.h index 02fc27aa6f..3d5e22157c 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationregiongrow_Activator.h @@ -1,41 +1,41 @@ /*=================================================================== 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 org_mitk_gui_qt_classificationsegmentation_Activator_h -#define org_mitk_gui_qt_classificationsegmentation_Activator_h +#ifndef org_mitk_gui_qt_classificationregiongrow_Activator_h +#define org_mitk_gui_qt_classificationregiongrow_Activator_h #include namespace mitk { -class org_mitk_gui_qt_classificationsegmentation_Activator : +class org_mitk_gui_qt_classificationregiongrow_Activator : public QObject, public ctkPluginActivator { Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_classificationsegmentation") + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_classificationregiongrow") Q_INTERFACES(ctkPluginActivator) public: void start(ctkPluginContext* context); void stop(ctkPluginContext* context); -}; // org_mitk_gui_qt_classificationsegmentation_Activator +}; // org_mitk_gui_qt_classificationregiongrow_Activator } -#endif // org_mitk_gui_qt_classificationsegmentation_Activator_h +#endif // org_mitk_gui_qt_classificationregiongrow_Activator_h diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp index 3fb6fb829a..c796fd6af2 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp @@ -1,33 +1,35 @@ /*=================================================================== 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 "org_mitk_gui_qt_classificationsegmentation_Activator.h" #include "ClassificationSegmentation.h" +#include "ClassificationRegionGrow.h" namespace mitk { void org_mitk_gui_qt_classificationsegmentation_Activator::start(ctkPluginContext* context) { BERRY_REGISTER_EXTENSION_CLASS(ClassificationSegmentation, context) + BERRY_REGISTER_EXTENSION_CLASS(ClassificationRegionGrow, context) } void org_mitk_gui_qt_classificationsegmentation_Activator::stop(ctkPluginContext* context) { Q_UNUSED(context) } } diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h index 02fc27aa6f..f6d899f134 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h @@ -1,41 +1,42 @@ /*=================================================================== 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 org_mitk_gui_qt_classificationsegmentation_Activator_h #define org_mitk_gui_qt_classificationsegmentation_Activator_h #include namespace mitk { class org_mitk_gui_qt_classificationsegmentation_Activator : public QObject, public ctkPluginActivator { Q_OBJECT Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_classificationsegmentation") +// Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_classificationregiongrow") Q_INTERFACES(ctkPluginActivator) public: void start(ctkPluginContext* context); void stop(ctkPluginContext* context); }; // org_mitk_gui_qt_classificationsegmentation_Activator } #endif // org_mitk_gui_qt_classificationsegmentation_Activator_h diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/CMakeLists.txt b/Plugins/org.mitk.gui.qt.preprocessing.resampling/CMakeLists.txt new file mode 100644 index 0000000000..cd46837ebb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/CMakeLists.txt @@ -0,0 +1,9 @@ + +project(org_mitk_gui_qt_preprocessing_resampling) + +mitk_create_plugin( + EXPORT_DIRECTIVE PREPROCESSING_RESAMPLING_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkQtWidgetsExt MitkMapperExt MitkImageDenoising + PACKAGE_DEPENDS ITK|ITKMathematicalMorphology +) diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing.dox b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing.dox new file mode 100644 index 0000000000..bff25497fa --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing.dox @@ -0,0 +1,126 @@ +/** +\page org_mitk_views_basicimageprocessing The Basic Image Processing Plugin + +\imageMacro{QmitkBasicImageProcessing_ImageProcessing_48.png,"Icon of the Basic Image Processing Plugin",2.00} + +\tableofcontents + +\section QmitkBasicImageProcessingUserManualSummary Summary + +This view provides an easy interface to fundamental image preprocessing and enhancement filters. +It offers filter operations on 3D and 4D images in the areas of noise suppression, morphological operations, edge detection and image arithmetics, +as well as image inversion and downsampling. + +Please see \ref QmitkBasicImageProcessingUserManualOverview for more detailed information on usage and supported filters. +If you encounter problems using the view, please have a look at the \ref QmitkBasicImageProcessingUserManualTrouble page. + +\section QmitkBasicImageProcessingUserManualOverview Overview + +This view provides an easy interface to fundamental image preprocessing and image enhancement filters. +It offers a variety of filter operations in the areas of noise suppression, morphological operations, edge detection and image arithmetics. +Currently the view can be used with all 3D and 4D image types loadable by MITK. +2D image support will be added in the future. +All filters are encapsulated from the Insight Segmentation and Registration Toolkit (ITK, www.itk.org). + +\imageMacro{QmitkBasicImageProcessing_BIP_Overview.png,"MITK with the Basic Image Processing view",16.00} + +This document will tell you how to use this view, but it is assumed that you already know how to use MITK in general. + +\section QmitkBasicImageProcessingUserManualFilters Filters + +This section will not describe the fundamental functioning of the single filters in detail, though. +If you want to know more about a single filter, please have a look at http://www.itk.org/Doxygen316/html/classes.html +or in any good digital image processing book. For total denoising filter, please see Tony F. Chan et al., "The digital TV filter and nonlinear denoising". + +Available filters are: + +

\a Single image operations

+ +
    +
  • Noise Suppression
  • +
      +
    • Gaussian Denoising
    • +
    • Median Filtering
    • +
    • Total Variation Denoising
    • +
    + +
  • Morphological Operations
  • +
      +
    • Dilation
    • +
    • Erosion
    • +
    • Opening
    • +
    • Closing
    • +
    + +
  • %Edge Detection
  • +
      +
    • Gradient Image
    • +
    • Laplacian Operator (Second Derivative)
    • +
    • Sobel Operator
    • +
    + +
  • Misc
  • +
      +
    • Threshold
    • +
    • Image Inversion
    • +
    • Downsampling (isotropic)
    • +
    +
+ +

\a Dual image operations

+ +
    +
  • Image Arithmetics
  • +
      +
    • Add two images
    • +
    • Subtract two images
    • +
    • Multiply two images
    • +
    • Divide two images
    • +
    + +
  • Binary Operations
  • +
      +
    • Logical AND
    • +
    • Logical OR
    • +
    • Logical XOR
    • +
    +
+ +\section QmitkBasicImageProcessingUserManualUsage Usage + +All you have to do to use a filter is to: +
    +
  • Load an image into MITK
  • +
  • Select it in data manager +
  • Select which filter you want to use via the drop down list
  • +
  • Press the execute button
  • +
+A busy cursor appeares; when it vanishes, the operation is completed. Your filtered image is displayed and selected for further processing. +(If the checkbox "Hide original image" is not selected, you will maybe not see the filter result imideately, +because your filtered image is possibly hidden by the original.) + +For two image operations, please make sure that the correct second image is selected in the drop down menu, and the image order is correct. +For sure, image order only plays a role for image subtraction and division. These are conducted (Image1 - Image2) or (Image1 / Image2), respectively. + +Please Note: When you select a 4D image, you can select the time step for the filter to work on via the time slider at the top of the GUI. +The 3D image at this time step is extracted and processed. The result will also be a 3D image. +This means, a true 4D filtering is not yet supported. + +\section QmitkBasicImageProcessingUserManualTrouble Troubleshooting + +I get an error when using a filter on a 2D image.
+2D images are not yet supported... + +I use a filter on a 4D image, and the output is 3D.
+When you select a 4D image, you can select the time step for the filter to work on via the time slider at the top of the GUI. +The 3D image at this time step is extracted and processed. The result will also be a 3D image. +This means, a true 4D filtering is not supported by now. + +A filter crashes during execution.
+Maybe your image is too large. Some filter operations, like derivatives, take a lot of memory. +Try downsampling your image first. + +All other problems.
+Please report to the MITK mailing list. +See http://www.mitk.org/wiki/Mailinglist on how to do this. +*/ diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_BIP_Overview.png b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_BIP_Overview.png new file mode 100644 index 0000000000..3515cb8e1e Binary files /dev/null and b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_BIP_Overview.png differ diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_ImageProcessing_48.png b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_ImageProcessing_48.png new file mode 100644 index 0000000000..27dc941ac4 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/UserManual/QmitkBasicImageProcessing_ImageProcessing_48.png differ diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..7bf036aa2a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_basicimageprocessing org.mitk.gui.qt.basicimageprocessing + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_basicimageprocessing_internal Internal + \ingroup org_mitk_gui_qt_basicimageprocessing + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.basicimageprocessing plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/files.cmake b/Plugins/org.mitk.gui.qt.preprocessing.resampling/files.cmake new file mode 100644 index 0000000000..8c61cd6c08 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/files.cmake @@ -0,0 +1,35 @@ +set(SRC_CPP_FILES + +) + +set(INTERNAL_CPP_FILES + QmitkPreprocessingResamplingView.cpp + mitkPreprocessingResamplingActivator.cpp +) + +set(UI_FILES + src/internal/QmitkPreprocessingResamplingViewControls.ui +) + +set(MOC_H_FILES + src/internal/QmitkPreprocessingResamplingView.h + src/internal/mitkPreprocessingResamplingActivator.h +) + +set(CACHED_RESOURCE_FILES + resources/lena.xpm + plugin.xml +) + +set(QRC_FILES + resources/QmitkPreprocessingResamplingView.qrc +) + +foreach(file ${SRC_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) + diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake new file mode 100644 index 0000000000..0eba5ba0eb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Preprocessing Resampling") +set(Plugin-Version "1.0") +set(Plugin-Vendor "DKFZ; Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common.legacy) diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/plugin.xml b/Plugins/org.mitk.gui.qt.preprocessing.resampling/plugin.xml new file mode 100644 index 0000000000..98e852ca8a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/plugin.xml @@ -0,0 +1,20 @@ + + + + + + Resampling an Image to an specific sizes + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/ImageProcessing_64.xpm b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/ImageProcessing_64.xpm new file mode 100644 index 0000000000..9265a814a2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/ImageProcessing_64.xpm @@ -0,0 +1,318 @@ +/* XPM */ +static char *ImageProcessing___[] = { +/* columns rows colors chars-per-pixel */ +"64 64 248 2", +" c #3F3235", +". c #572F3A", +"X c #592F3A", +"o c #463337", +"O c #483137", +"+ c #513037", +"@ c #503138", +"# c #503039", +"$ c #533038", +"% c #533138", +"& c #533139", +"* c #553039", +"= c #5B313C", +"- c #612F3B", +"; c #622E3B", +": c #632F3B", +"> c #652F3C", +", c #682E3C", +"< c #6F2D3E", +"1 c #712E3E", +"2 c #752D3E", +"3 c #742C3F", +"4 c #752C3F", +"5 c #7A2D40", +"6 c #6E3F4A", +"7 c #743F4D", +"8 c #773F4C", +"9 c #7B3D4C", +"0 c #783E4C", +"q c #7B3E4D", +"w c #7D3D4C", +"e c gray30", +"r c #5B444B", +"t c #67434C", +"y c #67434D", +"u c #62454C", +"i c #62464D", +"p c #62474D", +"a c #62464E", +"s c #65444C", +"d c #65454C", +"f c #66444C", +"g c #67444C", +"h c #66444D", +"j c #67444D", +"k c #66454D", +"l c #67454D", +"z c #64464D", +"x c #66464D", +"c c #67454E", +"v c #66464F", +"b c #68434C", +"n c #6E404C", +"m c #6F414D", +"M c #6D424C", +"N c #6E424C", +"B c #68444C", +"V c #69444C", +"C c #68454D", +"Z c #70414C", +"A c #71414C", +"S c #71404D", +"D c #70414D", +"F c #72404C", +"G c #73404D", +"H c #744651", +"J c #7D4351", +"K c #7D4F59", +"L c #665659", +"P c #615B5C", +"I c gray40", +"U c #676767", +"Y c #686868", +"T c DimGray", +"R c #6A6A6A", +"E c gray42", +"W c #6C6B6C", +"Q c #6C6C6C", +"! c #6D6D6D", +"~ c #717171", +"^ c #727272", +"/ c gray45", +"( c #747474", +") c gray46", +"_ c #767676", +"` c #777777", +"' c gray47", +"] c gray48", +"[ c #7B7B7B", +"{ c #7C7C7C", +"} c #852B41", +"| c #822D40", +" . c #8A2B42", +".. c #8C2B42", +"X. c #8E2A42", +"o. c #892C42", +"O. c #962B45", +"+. c #9E2A46", +"@. c #8D364C", +"#. c #833A4B", +"$. c #803B4C", +"%. c #823A4C", +"&. c #853A4C", +"*. c #863A4C", +"=. c #863A4D", +"-. c #813C4C", +";. c #833C4D", +":. c #88394C", +">. c #8B384C", +",. c #97344B", +"<. c #90364C", +"1. c #92374D", +"2. c #94344C", +"3. c #98334B", +"4. c #9F324B", +"5. c #9F304C", +"6. c #9D324C", +"7. c #AD2748", +"8. c #A22F4B", +"9. c #A42F4B", +"0. c #A72E4B", +"q. c #AF2848", +"w. c #AB2D4B", +"e. c #AC2D4B", +"r. c #AA2D4C", +"t. c #AD2C4C", +"y. c #B6274A", +"u. c #B7274A", +"i. c #B8274A", +"p. c #BB274B", +"a. c #BD264B", +"s. c #BD274B", +"d. c #BE264B", +"f. c #BF264B", +"g. c #BE274B", +"h. c #BF274B", +"j. c #B32A4B", +"k. c #B22B4B", +"l. c #B7284B", +"z. c #B6294B", +"x. c #B42A4B", +"c. c #B52A4B", +"v. c #B42A4C", +"b. c #B62A4C", +"n. c #B9284B", +"m. c #BA284B", +"M. c #BB284B", +"N. c #B9294C", +"B. c #A1304C", +"V. c #A2304C", +"C. c #B73152", +"Z. c #AB445D", +"A. c #825962", +"S. c #9D5667", +"D. c #95606E", +"F. c #95616E", +"G. c #93646F", +"H. c #8F6A72", +"J. c #8B7077", +"K. c #8C7077", +"L. c #8D777D", +"P. c #88797D", +"I. c #937077", +"U. c #907A7F", +"Y. c #897D81", +"T. c #8A7D80", +"R. c #8A7D81", +"E. c #8B7E81", +"W. c #8C7D82", +"Q. c #A87C85", +"!. c #808080", +"~. c #818181", +"^. c gray51", +"/. c #838383", +"(. c #848081", +"). c #868084", +"_. c #848484", +"`. c gray52", +"'. c gray53", +"]. c #8C8485", +"[. c #8D8485", +"{. c #8E8486", +"}. c #8F8487", +"|. c #8A8588", +" X c #8E8789", +".X c #888888", +"XX c #898989", +"oX c gray54", +"OX c #8F8889", +"+X c gray55", +"@X c #8D8C8D", +"#X c #8D8D8D", +"$X c #918586", +"%X c #908587", +"&X c #918587", +"*X c #928588", +"=X c #938588", +"-X c #96878A", +";X c #97878B", +":X c #918E8F", +">X c #99888B", +",X c #9A888B", +".f.f.f.s.9 FXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXg 0.f.f.f.j.M FXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX7 n.f.f.f.V.j FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXa @.f.f.f.h.=.FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXy r.f.f.f.b.S FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX8 m.f.f.f.B.c FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXi 1.f.f.f.h.&.FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXB w.f.f.f.v.D FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX0 M.f.f.f.4.h FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXu 2.f.f.f.g.;.FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXb t.f.f.f.j.N FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXq p.f.f.f.6.C FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXh 3.f.f.f.a.$.FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXr 9.f.f.f.k.M FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXT L d.f.n.%.d FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX& > , = W AXlXv 9 B FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX4 u.f.f.7.(.SXhXe FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX@ X.f.f.f.f.f.J P FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX+ +.f.f.f.f.f.f.f.5 FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXo . f.f.f.f.f.f.f.d.X FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFX2 $ q.f.f.f.f.f.f.o.FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFX* p.; | y.f.f.f.i.< FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFX3 f... O } 1 : # FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXO. .% FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFX- FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFX[ ! E E E E E ` XCXDXDXDXDXDXCXaXDXDXDXDXDXDX:XkXmXmXmXmXmX9X_ I I I I I U !.mXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) uXVXK 6 VXVXNX*XVXVXVXVXVXVX>XCXDXDXDXDXDXCXaXDXDXDXDXDXDX:XkXmXmXmXmXmX9X_ I I I I I U !.mXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) uXVXQ.rXVXVXNX*XVXVXVXVXVXVX>XCXDXDXDXDXDXCXaXDXDXDXDXDXDX:XkXmXmXmXmXmX9X_ I I I I I U !.mXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) uXVXVXVXVXVXNX*XVXVXVXVXVXVX>XCXDXDXDXDXDXCXaXDXDXDXDXDXDX:XkXmXmXmXmXmX9X_ I I I I I U !.mXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) uXVXVXVXVXVXNX*XVXVXVXVXVXVX>XCXDXDXDXDXDXCXaXDXDXDXDXDXDX:XkXmXmXmXmXmX9X_ I I I I I U !.mXmXmXmXmXmX6XFXFX", +"FXFX{ / ~ ~ ~ ~ ~ ] =XpXpXpXpXpXiX%XpXpXpXpXpXpX&XdXvXvXvXvXvXdX5XvXvXvXvXvXvX@XqXwXwXwXwXwX+X[ ~ ~ ~ ~ ~ ^ ~.wXwXwXwXwXwX#XFXFX", +"FXFXFX2X2X2X2X2X2XoXK.D.D.D.D.D.G.W.,X,X,X,X,X,X[.H.D.D.D.D.D.H.J.D.D.D.D.D.D.P.1X2X2X2X2X2XXXXX2X2X2X2X2X2X/._ _ _ _ _ _ { FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXoXbXmXmXmXmXmX8XS.f.f.f.f.f.C.U.VXVXVXVXVXVX>XZ.f.f.f.f.f.Z.F.f.f.f.f.f.f.L.kXmXmXmXmXmX9X6XmXmXmXmXmXnX/.I I I I I I ) FXFX", +"FXFXFX^.^.^.^.^.^._.Y.T.T.T.T.T.R.].}.}.}.}.}.}.{.E.T.T.T.T.T.E.T.T.T.T.T.T.T.).^.^.^.^.^.^.~.XXoXoXoXoXoXoX'.^.^.^.^.^.^._.FXFX", +"FXFX[ R Y Y Y Y Y _ 8XxXxXxXxXxXjX XBXBXBXBXBXBX;XeXxXxXxXxXxXeX1XxXxXxXxXxXxX`.Q Y Y Y Y Y ) 3XxXxXxXxXxXzXXXxXxXxXxXxXxX4XFXFX", +"FXFX[ Y I I I I I ) 9XmXmXmXmXmXzXOXVXVXVXVXVXVX>XfXmXmXmXmXmXfX2XmXmXmXmXmXmX_.R I I I I I / 6XmXmXmXmXmXnXXXmXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) 9XmXmXmXmXmXzXOXVXVXVXVXVXVX>XfXmXmXmXmXmXfX2XmXmXmXmXmXmX_.R I I I I I / 6XmXmXmXmXmXnXXXmXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) 9XmXmXmXmXmXzXOXVXVXVXVXVXVX>XfXmXmXmXmXmXfX2XmXmXmXmXmXmX_.R I I I I I / 6XmXmXmXmXmXnXXXmXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) 9XmXmXmXmXmXzXOXVXVXVXVXVXVX>XfXmXmXmXmXmXfX2XmXmXmXmXmXmX_.R I I I I I / 6XmXmXmXmXmXnXXXmXmXmXmXmXmX6XFXFX", +"FXFX[ Y I I I I I ) 9XmXmXmXmXmXzXOXVXVXVXVXVXVX>XfXmXmXmXmXmXfX2XmXmXmXmXmXmX_.R I I I I I / 6XmXmXmXmXmXnXXXmXmXmXmXmXmX6XFXFX", +"FXFX{ ) ( ( ( ( ( { XX7X7X7X7X7X4X|.yXyXyXyXyXyX[.#X7X7X7X7X7X#XXX7X7X7X7X7X7X/._ ( ( ( ( ( { .X7X7X7X7X7X6X'.7X7X7X7X7X7XoXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX", +"FXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFXFX" +}; diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/QmitkPreprocessingResamplingView.qrc b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/QmitkPreprocessingResamplingView.qrc new file mode 100644 index 0000000000..d8074b5c48 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/QmitkPreprocessingResamplingView.qrc @@ -0,0 +1,5 @@ + + + lena.xpm + + diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/lena.xpm b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/lena.xpm new file mode 100644 index 0000000000..dbe157cb21 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/resources/lena.xpm @@ -0,0 +1,391 @@ +/* XPM */ +static char * pixmap[] = { +/* width height num_colors chars_per_pixel */ +"48 48 336 4", +/* colors */ +" c #FDFDFD", +"! c #FCFCFC", +"# c #FBFBFB", +"$ c #F5F5F5", +"% c #F3F3F3", +"& c #EFEFEF", +"' c #EEEEEE", +"( c #EBEBEB", +") c #EAEAEA", +"* c #E9E9E9", +"+ c #E6E6E6", +", c #E5E5E5", +"- c #E1E1E1", +". c #DDDDDD", +"/ c #D9D9D9", +"0 c #D1D1D1", +"1 c #D0D0D0", +"2 c #CCCCCC", +"3 c #C7C7C7", +"4 c #C0C0C0", +"5 c #BFBFBF", +"6 c #BBBBBB", +"7 c #BABABA", +"8 c #B8B9B6", +"9 c #B6B6B6", +": c #B5B5B5", +"; c #B4B4B4", +"< c #B2B2B2", +"= c #B1B1B1", +"> c #ABABAB", +"? c #AAAAAA", +"@ c #A9A9A9", +"A c #A8A8A8", +"B c #A7A7A7", +"C c #A6A6A5", +"D c #A5A5A5", +"E c #A5A5A4", +"F c #A3A3A3", +"G c #A0A0A0", +"H c #9FA09F", +"I c #9E9F99", +"J c #9D9D9A", +"K c #9C9C9B", +"L c #9B9B9B", +"M c #999999", +"N c #989898", +"O c #989895", +"P c #979797", +"Q c #979796", +"R c #949494", +"S c #939393", +"T c #929292", +"U c #919191", +"V c #909090", +"W c #8F8F8F", +"X c #8E8E8E", +"Y c #8D8D8D", +"Z c #8C8C8C", +"[ c #8B8B8B", +"] c #8A8A8A", +"^ c #888888", +"_ c #878787", +"` c #868686", +"a c #858585", +"b c #848484", +"c c #838383", +"d c #828282", +"e c #818181", +"f c #7F7F7F", +"g c #7E7F7E", +"h c #7E7E7E", +"i c #7E7E7D", +"j c #7C7D7A", +"k c #7C7C7C", +"l c #7B7B7B", +"m c #7B7B7A", +"n c #7A7C73", +"o c #7A7A7A", +"p c #797A7A", +"q c #797979", +"r c #787979", +"s c #787878", +"t c #777875", +"u c #777777", +"v c #767777", +"w c #767770", +"x c #76776F", +"y c #767676", +"z c #767675", +"{ c #747474", +"| c #747473", +"} c #737373", +"~ c #737370", +" ! c #727371", +"!! c #727272", +"#! c #71736A", +"$! c #71726A", +"%! c #717171", +"&! c #707170", +"'! c #707070", +"(! c #70706E", +")! c #6F6F6F", +"*! c #6F6F6E", +"+! c #6E6F6E", +",! c #6E6E6E", +"-! c #6E6E6C", +".! c #6D6D6D", +"/! c #6C6E64", +"0! c #6C6C6C", +"1! c #6B6B6B", +"2! c #6A6A6A", +"3! c #696A6A", +"4! c #696969", +"5! c #696867", +"6! c #686968", +"7! c #686868", +"8! c #676767", +"9! c #676766", +":! c #666764", +";! c #666666", +"! c #646464", +"?! c #646463", +"@! c #63655C", +"A! c #636462", +"B! c #636363", +"C! c #636362", +"D! c #626262", +"E! c #626261", +"F! c #616161", +"G! c #616160", +"H! c #606160", +"I! c #606060", +"J! c #60605F", +"K! c #5F605F", +"L! c #5F5F5F", +"M! c #5E5F5E", +"N! c #5E5E5E", +"O! c #5D5D5E", +"P! c #5D5D5D", +"Q! c #5C5C5C", +"R! c #5B5B5B", +"S! c #5A5A5A", +"T! c #5A5A59", +"U! c #595959", +"V! c #595958", +"W! c #59585C", +"X! c #585858", +"Y! c #575758", +"Z! c #575757", +"[! c #565753", +"]! c #565656", +"^! c #565655", +"_! c #555556", +"`! c #555555", +"a! c #545454", +"b! c #545453", +"c! c #535353", +"d! c #535352", +"e! c #525252", +"f! c #515152", +"g! c #515151", +"h! c #505050", +"i! c #4F4F4F", +"j! c #4E4E4E", +"k! c #4D4D4D", +"l! c #4D4D4C", +"m! c #4C4C4C", +"n! c #4B4B4B", +"o! c #4A4B43", +"p! c #4A4A4A", +"q! c #4A4A49", +"r! c #494B42", +"s! c #494949", +"t! c #484A41", +"u! c #484848", +"v! c #474748", +"w! c #474747", +"x! c #46473F", +"y! c #464646", +"z! c #45473F", +"{! c #454545", +"|! c #444444", +"}! c #444443", +"~! c #43443C", +" # c #434343", +"!# c #42443B", +"## c #42443A", +"$# c #424242", +"%# c #424241", +"&# c #414242", +"'# c #414141", +"(# c #414140", +")# c #404040", +"*# c #3F3F3F", +"+# c #3F3F3E", +",# c #3E3E3E", +"-# c #3E3E3D", +".# c #3D3F37", +"/# c #3D3E37", +"0# c #3D3D3D", +"1# c #3D3D3A", +"2# c #3C3C3C", +"3# c #3B3C3B", +"4# c #3B3B3B", +"5# c #393939", +"6# c #393938", +"7# c #35372F", +"8# c #353535", +"9# c #34352D", +":# c #343434", +";# c #33352C", +"<# c #333433", +"=# c #333331", +"># c #32332A", +"?# c #323232", +"@# c #313131", +"A# c #303228", +"B# c #303129", +"C# c #303030", +"D# c #2F3030", +"E# c #2F302E", +"F# c #2F3028", +"G# c #2F3027", +"H# c #2F3021", +"I# c #2F2F2F", +"J# c #2F2F2E", +"K# c #2F2E2D", +"L# c #2E3027", +"M# c #2E2F27", +"N# c #2E2E2E", +"O# c #2D2E2D", +"P# c #2D2E26", +"Q# c #2D2D2D", +"R# c #2C2E25", +"S# c #2C2D29", +"T# c #2C2C2C", +"U# c #2C2C2B", +"V# c #2B2C24", +"W# c #2B2B2C", +"X# c #2A2A2B", +"Y# c #292B22", +"Z# c #292A29", +"[# c #292A21", +"]# c #282827", +"^# c #272920", +"_# c #272726", +"`# c #262820", +"a# c #262627", +"b# c #262626", +"c# c #262625", +"d# c #25271F", +"e# c #252525", +"f# c #242524", +"g# c #24251E", +"h# c #242424", +"i# c #242423", +"j# c #23251D", +"k# c #23241C", +"l# c #23241B", +"m# c #232323", +"n# c #232322", +"o# c #222222", +"p# c #21231A", +"q# c #21221A", +"r# c #212219", +"s# c #202219", +"t# c #20211A", +"u# c #202119", +"v# c #202118", +"w# c #202020", +"x# c #202018", +"y# c #201F18", +"z# c #1F2119", +"{# c #1F2118", +"|# c #1F2020", +"}# c #1F201E", +"~# c #1F2018", +" $ c #1F2017", +"!$ c #1F1F1F", +"#$ c #1F1F1E", +"$$ c #1F1F18", +"%$ c #1E2017", +"&$ c #1E1E1E", +"'$ c #1E1E1D", +"($ c #1D1E16", +")$ c #1D1D1C", +"*$ c #1C1E16", +"+$ c #1C1C1D", +",$ c #1C1C1C", +"-$ c #1C1B1A", +".$ c #1B1B1B", +"/$ c #1B1B1A", +"0$ c #1A1A1A", +"1$ c #191919", +"2$ c #191819", +"3$ c #181918", +"4$ c #181818", +"5$ c #171717", +"6$ c #171714", +"7$ c #161616", +"8$ c #161615", +"9$ c #161514", +":$ c #151515", +";$ c #141514", +"<$ c #141415", +"=$ c #141413", +">$ c #141313", +"?$ c #131313", +"@$ c #131312", +"A$ c #121213", +"B$ c #121212", +"C$ c #121211", +"D$ c #111111", +"E$ c #111110", +"F$ c #101110", +"G$ c #101010", +"H$ c #0F0F0F", +"I$ c #0E0F0E", +"J$ c #0E0E0F", +"K$ c #0E0E0E", +"L$ c #0E0E0D", +"M$ c #0E0D0E", +"N$ c #0E0D0D", +"O$ c #0E0D0C", +"P$ c #0D0D0E", +"Q$ c #0D0D0D", +"R$ c #0D0D0C", +"S$ c #0D0C0C", +"T$ c #0D0C0B", +"U$ c #0C0C0D", +"V$ c #0C0C0C", +"W$ c #0C0C0B", +"X$ c #0B0B0B", +"Y$ c #0B0B0A", +/* pixels */ +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t O 8 J I w x! /# o! .# P# j# z# k# `# P# t# ($ *$ ($ $$ y# H# ", +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t A! K P! V! 2! v N 3! h v :# .$ 4$ ?$ 2$ .$ K$ Q$ N$ M$ O$ $$ ", +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t q! =! W! f! _! X! p S! ;! h : I! 5$ |# h# 0$ ;$ K$ R$ S$ Y$ z# ", +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t m! |! y! a! e! `! %! B! c! F! D! %! e T# 0$ .$ w# D$ I$ P$ L$ r# ", +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t g! )# w! P! =! c! 2! 8! k! Q! `! 1! 0! 4! w# &$ ,$ e# L$ K$ S$ v# ", +"g# g# g# g# g# g# S# S# S# S# S# S# [! [! [! [! [! [! j j j j j j t t s! $# '# p! n! s! L! B! k! Z! k! Z! D! [ b b# 0$ 5$ 3$ Q$ N$ ~# ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! D! w! )# # {! ]! =! e! p! Z! m! ]! ;! P! %! y! h# .$ )$ D$ T$ v# ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! .! n! ,# ,# w! F! g! p! y! # w! # y! e! S! U! m# .$ /$ +$ N$ $ ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! N! u! )# '# y! N! ]! n! n! w! |! n! R! 4! 0! ` ,# b# ]# .$ >$ q# ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! S! u! $# $# |! n! u! '# # y! u! X! .! =! F! e w# o# i# a# 9$ {# ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! k! *# # $# # |! y! p! 2! !! N! i! 2! 7! )! R! 0$ 1$ O# 8# #$ l# ", +"1# 1# 1# 1# 1# 1# =! =! =! =! =! =! h! h! h! h! h! h! I! I! I! I! I! I! S! S! y! {! g! m! *# )# {! U! =! ,! u l } u !! $# 4$ &$ U# 4# _# V# ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! {! a! l j! ,# y! n! R! D! N! F! .! ' L U! j! u! 4$ E# *# f# F# ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! X! 4! 2! Q! n! p! p! n! U! S! L! F , # ( > X! I# Z# C# +# ># ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! d =! I! S! ]! R! i! m! e! =! _ 1 Z * / + % C# '$ D# c# ;# ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! ,! I! a! i! N! P! R! j! S! 2! %! ,! %! W ? 4 - ; 7$ 0$ J# z! ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! e h! ,# i! N! N! Q! R! a! P! 0! l ,! s y { T 5 -# A$ #$ ~! ", +":! :! :! :! :! :! L L L L L L l l l l l l h h h h h h L! L! > {! )# $# c! D! X! g! g! X! 1! %! )! U U )! 7! D H <$ -$ F# ", +"(! (! (! (! (! (! 5 5 5 5 5 5 l l l l l l ,! ,! ,! ,! ,! ,! R! R! P i! # 2# {! k! g! j! e! a! I! 1! a 7 Z y o A C F! C$ B# ", +"(! (! (! (! (! (! 5 5 5 5 5 5 l l l l l l ,! ,! ,! ,! ,! ,! R! R! >! w! # {! ,# w! g! Q! n! Z! I! ,! B 0 B V k Y E ^ }# G# ", +"(! (! (! (! (! (! 5 5 5 5 5 5 l l l l l l ,! ,! ,! ,! ,! ,! R! R! j! p! w! s! $# 0# m! {! s! Z! D! } P + U 2! )! S! ! e! h! k! l! h! ^! x ", +"-! -! -! -! -! -! 9 9 9 9 9 9 d d d d d d F! F! F! F! F! F! I! I! } D! P! Q! c! g! m! k! k! X! L! a! c! F! c! s! j! c! M! !! 5! /! ", +"-! -! -! -! -! -! 9 9 9 9 9 9 d d d d d d F! F! F! F! F! F! I! I! D 0! Z! Q! ]! e! i! n! n! h! h! g! ]! e! c! c! e! R! +! a Q @! ", +"-! -! -! -! -! -! 9 9 9 9 9 9 d d d d d d F! F! F! F! F! F! I! I! h f u L! Q! c! c! m! |! s! m! ]! c! i! c! `! Q! L! E! B! G! n ", +"-! -! -! -! -! -! 9 9 9 9 9 9 d d d d d d F! F! F! F! F! F! I! I! X! a! k! '! b ] P .! j! s! h! `! n! h! c! Z! =! 4! H! N! ! = & ) $ F p! m! m! m! S! 7! 1! ` c &! >! 9! r! ", +"~ ~ ~ ~ ~ ~ @ @ @ @ @ @ X X X X X X u u u u u u =! =! h! c! U! S! ] ( # 3 h! a! e! e! 2! %! .! 7! 4! C! >! *! A# ", +"~ ~ ~ ~ ~ ~ @ @ @ @ @ @ X X X X X X u u u u u u =! =! ;! S! h! Z! R! R . ! 2 c! g! n! `! P! >! 4! )! { m e b! L# ", +"~ ~ ~ ~ ~ ~ @ @ @ @ @ @ X X X X X X u u u u u u =! =! '! c! i! ]! a! N! y 6 < c! g! i! g! c! `! ]! ]! 2! g T }! [# ", +"~ ~ ~ ~ ~ ~ @ @ @ @ @ @ X X X X X X u u u u u u =! =! 8! P! h! `! a! a! ]! N! o a! e! e! F! B! Q! `! j! F! 6! =! K# M# ", +"~ ~ ~ ~ ~ ~ @ @ @ @ @ @ X X X X X X u u u u u u =! =! S! R! S! ,! y U! U! c! S! g! g! c! R! { } 2! P! P! C! k! /$ R# ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o } M a = '! c! `! Q! P! `! g! n! u! Z! >! 1! Z e ! # E$ d# ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o ^ '! U! V >! a! U! S! Z! c! e! h! j! k! j! `! L! 8! ?! !$ =$ 7# ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o .! 1! j! g! ]! `! X! Z! g! c! c! R! D! I! X! P! =! 7! d! B$ ;$ ## ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o S! g! i! g! `! U! Q! k! S! Q! S! S! B! 4! `! I! 7! s @$ G$ (# !# ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o N! ]! a! `! `! Z! R! g! ]! !! q 2! P! { S! 8! M Q# F$ &$ <# Y# ", +"=# =# =# =# =# =# [ [ [ [ [ [ !! !! !! !! !! !! X! X! X! X! X! X! o o 1! >! g! >! S! X! `! a! R! 2! q )! 7! y R! P! {! 1$ n# 5# i# x# ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } D! >! D! )! 2! L! N! g! Z! 4! B! q d e %! ]! ?$ 4$ 3# &# 8$ u# ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } P! !! } X! U! R! a! e! ]! 1! u %! B 7 m! 4$ 7$ N# 6# 0$ L$ v# ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } F! c! u ]! Z! c! `! k! c! >! '! 4! 0! w! :$ :$ h# $# '$ H$ N$ %$ ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } Z! `! g! Z! S! h! u L! e! c! Z! R! C# D$ 7$ @# ?# :$ X$ Q$ W$ s# ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } N! ]! w! I! P! i! 4! a S! D! w! 4$ :$ ?$ T# I# G$ V$ W$ V$ W$ p# ", +"6$ 6$ 6$ 6$ 6$ 6$ X# X# X# X# X# X# p! p! p! p! p! p! J! J! J! J! J! J! } } v! Y! Z! G Z! f! c! >! O! W# J$ .$ e# a# &$ D$ K$ H$ Q$ U$ R$ u# " +}; diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.cpp b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.cpp new file mode 100644 index 0000000000..749a3e3081 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.cpp @@ -0,0 +1,413 @@ +/*=================================================================== + +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 "QmitkPreprocessingResamplingView.h" + +// QT includes (GUI) +#include +#include +#include +#include +#include +#include +#include + +// Berry includes (selection service) +#include +#include + +// MITK includes (GUI) +#include "QmitkStdMultiWidget.h" +#include "QmitkDataNodeSelectionProvider.h" +#include "mitkDataNodeObject.h" + +// MITK includes (general) +#include "mitkNodePredicateDataType.h" +#include "mitkNodePredicateDimension.h" +#include "mitkNodePredicateAnd.h" +#include "mitkImageTimeSelector.h" +#include "mitkVectorImageMapper2D.h" +#include "mitkProperties.h" + +// Includes for image casting between ITK and MITK +#include "mitkImageCast.h" +#include "mitkITKImageImport.h" + +// ITK includes (general) +#include +#include + +// Resampling +#include +#include +#include +#include +#include + +#include +#include + + +// Convenient Definitions +typedef itk::Image ImageType; +typedef itk::Image SegmentationImageType; +typedef itk::Image DoubleImageType; +typedef itk::Image, 3> VectorImageType; + +typedef itk::ResampleImageFilter< ImageType, ImageType > ResampleImageFilterType; +typedef itk::ResampleImageFilter< ImageType, ImageType > ResampleImageFilterType2; +typedef itk::CastImageFilter< ImageType, DoubleImageType > ImagePTypeToFloatPTypeCasterType; + +typedef itk::LinearInterpolateImageFunction< ImageType, double > LinearInterpolatorType; +typedef itk::NearestNeighborInterpolateImageFunction< ImageType, double > NearestInterpolatorType; +typedef itk::BSplineInterpolateImageFunction BSplineInterpolatorType; + + +QmitkPreprocessingResampling::QmitkPreprocessingResampling() +: QmitkAbstractView(), + m_Controls(NULL), + m_SelectedImageNode(NULL), + m_TimeStepperAdapter(NULL) +{ +} + +QmitkPreprocessingResampling::~QmitkPreprocessingResampling() +{ +} + +void QmitkPreprocessingResampling::CreateQtPartControl(QWidget *parent) +{ + if (m_Controls == NULL) + { + m_Controls = new Ui::QmitkPreprocessingResamplingViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + + mitk::NodePredicateDimension::Pointer dimensionPredicate = mitk::NodePredicateDimension::New(3); + mitk::NodePredicateDataType::Pointer imagePredicate = mitk::NodePredicateDataType::New("Image"); + } + + m_SelectedImageNode = mitk::DataStorageSelection::New(this->GetDataStorage(), false); + + // Setup Controls + this->m_Controls->cbParam4->clear(); + this->m_Controls->cbParam4->insertItem(LINEAR, "Linear"); + this->m_Controls->cbParam4->insertItem(NEAREST, "Nearest neighbor"); + this->m_Controls->cbParam4->insertItem(SPLINE, "B-Spline"); + +} + +void QmitkPreprocessingResampling::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->btnDoIt), SIGNAL(clicked()),(QObject*) this, SLOT(StartButtonClicked())); + connect( (QObject*)(m_Controls->cbParam4), SIGNAL( activated(int) ), this, SLOT( SelectInterpolator(int) ) ); + } +} + +void QmitkPreprocessingResampling::InternalGetTimeNavigationController() +{ + auto renwin_part = GetRenderWindowPart(); + if( renwin_part != nullptr ) + { + auto tnc = renwin_part->GetTimeNavigationController(); + if( tnc != nullptr ) + { + m_TimeStepperAdapter = new QmitkStepperAdapter((QObject*) m_Controls->sliceNavigatorTime, tnc->GetTime(), "sliceNavigatorTimeFromBIP"); + } + } +} + +void QmitkPreprocessingResampling::SetFocus() +{ +} + +//datamanager selection changed +void QmitkPreprocessingResampling::OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList& nodes) +{ + ResetOneImageOpPanel(); + //any nodes there? + if (!nodes.empty()) + { + // reset GUI + m_Controls->sliceNavigatorTime->setEnabled(false); + m_Controls->leImage1->setText(tr("Select an Image in Data Manager")); + + m_SelectedImageNode->RemoveAllNodes(); + //get the selected Node + mitk::DataNode* _DataNode = nodes.front(); + *m_SelectedImageNode = _DataNode; + //try to cast to image + mitk::Image::Pointer tempImage = dynamic_cast(m_SelectedImageNode->GetNode()->GetData()); + + //no image + if( tempImage.IsNull() || (tempImage->IsInitialized() == false) ) + { + m_Controls->leImage1->setText(tr("Not an image.")); + return; + } + + //2D image + if( tempImage->GetDimension() < 3) + { + m_Controls->leImage1->setText(tr("2D images are not supported.")); + return; + } + + //image + m_Controls->leImage1->setText(QString(m_SelectedImageNode->GetNode()->GetName().c_str())); + mitk::Vector3D aSpacing = tempImage->GetGeometry()->GetSpacing(); + std::string text("x-spacing (" + std::to_string(aSpacing[0]) + ")"); + m_Controls->tlParam1->setText(text.c_str()); + text = "y-spacing (" + std::to_string(aSpacing[1]) + ")"; + m_Controls->tlParam2->setText(text.c_str()); + text = "z-spacing (" + std::to_string(aSpacing[2]) + ")"; + m_Controls->tlParam3->setText(text.c_str()); + MITK_INFO << "Spacing of current Image : " << aSpacing; +// m_Controls->tlParam1->setText("y-spacing"); +// m_Controls->tlParam1->setText("z-spacing"); + + // button coding + if ( tempImage->GetDimension() > 3 ) + { + // try to retrieve the TNC (for 4-D Processing ) + this->InternalGetTimeNavigationController(); + + m_Controls->sliceNavigatorTime->setEnabled(true); + m_Controls->tlTime->setEnabled(true); + } + ResetParameterPanel(); + } +} + +void QmitkPreprocessingResampling::ResetOneImageOpPanel() +{ + m_Controls->tlTime->setEnabled(false); + m_Controls->btnDoIt->setEnabled(false); + m_Controls->cbHideOrig->setEnabled(false); + m_Controls->leImage1->setText(tr("Select an Image in Data Manager")); + m_Controls->tlParam1->setText("x-spacing"); + m_Controls->tlParam1->setText("y-spacing"); + m_Controls->tlParam1->setText("z-spacing"); +} + +void QmitkPreprocessingResampling::ResetParameterPanel() +{ + m_Controls->btnDoIt->setEnabled(true); + m_Controls->cbHideOrig->setEnabled(true); +} + +void QmitkPreprocessingResampling::ResetTwoImageOpPanel() +{ +} + +void QmitkPreprocessingResampling::StartButtonClicked() +{ + if(!m_SelectedImageNode->GetNode()) return; + + this->BusyCursorOn(); + + mitk::Image::Pointer newImage; + + try + { + newImage = dynamic_cast(m_SelectedImageNode->GetNode()->GetData()); + } + catch ( std::exception &e ) + { + QString exceptionString = tr("An error occured during image loading:\n"); + exceptionString.append( e.what() ); + QMessageBox::warning( NULL, "Preprocessing - Resampling: ", exceptionString , QMessageBox::Ok, QMessageBox::NoButton ); + this->BusyCursorOff(); + return; + } + + // check if input image is valid, casting does not throw exception when casting from 'NULL-Object' + if ( (! newImage) || (newImage->IsInitialized() == false) ) + { + this->BusyCursorOff(); + + QMessageBox::warning( NULL, "Preprocessing - Resampling", tr("Input image is broken or not initialized. Returning."), QMessageBox::Ok, QMessageBox::NoButton ); + return; + } + + // check if operation is done on 4D a image time step + if(newImage->GetDimension() > 3) + { + mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); + timeSelector->SetInput(newImage); + timeSelector->SetTimeNr( ((QmitkSliderNavigatorWidget*)m_Controls->sliceNavigatorTime)->GetPos() ); + timeSelector->Update(); + newImage = timeSelector->GetOutput(); + } + + // check if image or vector image + ImageType::Pointer itkImage = ImageType::New(); + VectorImageType::Pointer itkVecImage = VectorImageType::New(); + + int isVectorImage = newImage->GetPixelType().GetNumberOfComponents(); + + if(isVectorImage > 1) + { + CastToItkImage( newImage, itkVecImage ); + } + else + { + CastToItkImage( newImage, itkImage ); + } + + std::stringstream nameAddition(""); + + double dparam1 = m_Controls->dsbParam1->value(); + double dparam2 = m_Controls->dsbParam2->value(); + double dparam3 = m_Controls->dsbParam3->value(); + + try{ + + std::string selectedInterpolator; + ResampleImageFilterType::Pointer resampler = ResampleImageFilterType::New(); + switch (m_SelectedInterpolation) + { + case LINEAR: + { + LinearInterpolatorType::Pointer interpolator = LinearInterpolatorType::New(); + resampler->SetInterpolator(interpolator); + selectedInterpolator = "Linear"; + break; + } + case NEAREST: + { + NearestInterpolatorType::Pointer interpolator = NearestInterpolatorType::New(); + resampler->SetInterpolator(interpolator); + selectedInterpolator = "Nearest"; + break; + } + case SPLINE: + { + BSplineInterpolatorType::Pointer interpolator = BSplineInterpolatorType::New(); + interpolator->SetSplineOrder(3); + resampler->SetInterpolator(interpolator); + selectedInterpolator = "B-Spline"; + break; + } + default: + { + LinearInterpolatorType::Pointer interpolator = LinearInterpolatorType::New(); + resampler->SetInterpolator(interpolator); + selectedInterpolator = "Linear"; + break; + } + } + resampler->SetInput( itkImage ); + resampler->SetOutputOrigin( itkImage->GetOrigin() ); + + ImageType::SizeType input_size = itkImage->GetLargestPossibleRegion().GetSize(); + ImageType::SpacingType input_spacing = itkImage->GetSpacing(); + + ImageType::SizeType output_size; + ImageType::SpacingType output_spacing; + + output_size[0] = input_size[0] * (input_spacing[0] / dparam1); + output_size[1] = input_size[1] * (input_spacing[1] / dparam2); + output_size[2] = input_size[2] * (input_spacing[2] / dparam3); + output_spacing [0] = dparam1; + output_spacing [1] = dparam2; + output_spacing [2] = dparam3; + + resampler->SetSize( output_size ); + resampler->SetOutputSpacing( output_spacing ); + resampler->SetOutputDirection( itkImage->GetDirection() ); + + resampler->UpdateLargestPossibleRegion(); + + ImageType::Pointer resampledImage = resampler->GetOutput(); + + newImage = mitk::ImportItkImage( resampledImage )->Clone(); + nameAddition << "_Resampled_" << selectedInterpolator; + std::cout << "Resampling successful." << std::endl; + } + catch (...) + { + this->BusyCursorOff(); + QMessageBox::warning(NULL, "Warning", "Problem when applying filter operation. Check your input..."); + return; + } + + newImage->DisconnectPipeline(); + + // adjust level/window to new image + mitk::LevelWindow levelwindow; + levelwindow.SetAuto( newImage ); + mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); + levWinProp->SetLevelWindow( levelwindow ); + + // compose new image name + std::string name = m_SelectedImageNode->GetNode()->GetName(); + if (name.find(".pic.gz") == name.size() -7 ) + { + name = name.substr(0,name.size() -7); + } + name.append( nameAddition.str() ); + + // create final result MITK data storage node + mitk::DataNode::Pointer result = mitk::DataNode::New(); + result->SetProperty( "levelwindow", levWinProp ); + result->SetProperty( "name", mitk::StringProperty::New( name.c_str() ) ); + result->SetData( newImage ); + + // for vector images, a different mapper is needed + if(isVectorImage > 1) + { + mitk::VectorImageMapper2D::Pointer mapper = + mitk::VectorImageMapper2D::New(); + result->SetMapper(1,mapper); + } + + // reset GUI to ease further processing +// this->ResetOneImageOpPanel(); + + // add new image to data storage and set as active to ease further processing + GetDataStorage()->Add( result, m_SelectedImageNode->GetNode() ); + if ( m_Controls->cbHideOrig->isChecked() == true ) + m_SelectedImageNode->GetNode()->SetProperty( "visible", mitk::BoolProperty::New(false) ); + // TODO!! m_Controls->m_ImageSelector1->SetSelectedNode(result); + + // show the results + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + this->BusyCursorOff(); +} + +void QmitkPreprocessingResampling::SelectInterpolator(int interpolator) +{ + switch (interpolator) + { + case 0: + { + m_SelectedInterpolation = LINEAR; + break; + } + case 1: + { + m_SelectedInterpolation = NEAREST; + break; + } + case 2: + { + m_SelectedInterpolation = SPLINE; + } + } +} diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h new file mode 100644 index 0000000000..2d478c8c01 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h @@ -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. + +===================================================================*/ + +#if !defined(QmitkPreprocessingResamplingView_H__INCLUDED) +#define QmitkPreprocessingResamplingView_H__INCLUDED + +#include +#include +#include "ui_QmitkPreprocessingResamplingViewControls.h" + +#include "QmitkStepperAdapter.h" + +#include + +/*! +\brief This module allows to use some basic image processing filters for preprocessing, image enhancement and testing purposes + +Several basic ITK image processing filters, like denoising, morphological and edge detection +are encapsulated in this module and can be selected via a list and an intuitive parameter input. +The selected filter will be applied on the image, and a new image showing the output is displayed +as result. +Also, some image arithmetic operations are available. + +Images can be 3D or 4D. +In the 4D case, the filters work on the 3D image selected via the +time slider. The result is also a 3D image. + +\sa QmitkFunctionality, QObject + +\class QmitkBasicImageProcessing +\author Tobias Schwarz +\version 1.0 (3M3) +\date 2009-05-10 +\ingroup Bundles +*/ + +class PREPROCESSING_RESAMPLING_EXPORT QmitkPreprocessingResampling : public QmitkAbstractView +{ + Q_OBJECT + +public: + + /*! + \brief default constructor + */ + QmitkPreprocessingResampling(); + + /*! + \brief default destructor + */ + virtual ~QmitkPreprocessingResampling(); + + /*! + \brief method for creating the widget containing the application controls, like sliders, buttons etc. + */ + virtual void CreateQtPartControl(QWidget *parent) override; + + virtual void SetFocus() override; + + /*! + \brief method for creating the connections of main and control widget + */ + virtual void CreateConnections(); + + /*! + \brief Invoked when the DataManager selection changed + */ + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList& nodes) override; + + + protected slots: + + /* + * The "Execute" button in the "one image ops" box was triggered + */ + void StartButtonClicked(); + + void SelectInterpolator(int interpolator); + +private: + + /* + * After a one image operation, reset the "one image ops" panel + */ + void ResetOneImageOpPanel(); + + /* + * Helper method to reset the parameter set panel + */ + void ResetParameterPanel(); + + /* + * After a two image operation, reset the "two image ops" panel + */ + void ResetTwoImageOpPanel(); + + /** retrieve the tnc from renderwindow part */ + void InternalGetTimeNavigationController(); + + /*! + * controls containing sliders for scrolling through the slices + */ + Ui::QmitkPreprocessingResamplingViewControls *m_Controls; + + //mitk::DataNode* m_SelectedImageNode; + mitk::DataStorageSelection::Pointer m_SelectedImageNode; + QmitkStepperAdapter* m_TimeStepperAdapter; + + enum InterpolationType{ + LINEAR, + NEAREST, + SPLINE + } m_SelectedInterpolation; +}; + +#endif // !defined(QmitkBasicImageProcessing_H__INCLUDED) + + diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingViewControls.ui b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingViewControls.ui new file mode 100644 index 0000000000..8d56270ada --- /dev/null +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingViewControls.ui @@ -0,0 +1,302 @@ + + + QmitkPreprocessingResamplingViewControls + + + + 0 + 0 + 448 + 980 + + + + Form + + + + + + Qt::Vertical + + + + 254 + 403 + + + + + + + + + + + true + + + + 0 + + + 6 + + + 0 + + + 6 + + + + + Select an Image in Data Manager + + + true + + + + + + + false + + + Output image will be 3D + + + Choose time step if 4D +(Slider for both images) + + + false + + + + + + + false + + + Output image will be 3D + + + + + + + + + + + + + true + + + + 0 + + + 6 + + + 0 + + + 0 + + + + + false + + + Resampling Parameter + + + false + + + + + + + false + + + x-spacing + + + false + + + + + + + false + + + y-spacing + + + false + + + + + + + false + + + &Execute + + + + + + + false + + + Hide Original Image + + + true + + + + + + + false + + + z-spacing + + + + + + + false + + + Interpolation: + + + + + + + true + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + Qt::LeftToRight + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 4 + + + 0.010000000000000 + + + 100.000000000000000 + + + 1.000000000000000 + + + + + + + true + + + + 0 + 0 + + + + 4 + + + 0.010000000000000 + + + 100.000000000000000 + + + 1.000000000000000 + + + + + + + true + + + + 0 + 0 + + + + 4 + + + 0.010000000000000 + + + 100.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + QmitkSliderNavigatorWidget + QWidget +
QmitkSliderNavigatorWidget.h
+
+
+ + +
diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.cpp similarity index 60% copy from Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp copy to Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.cpp index 3fb6fb829a..3f1fe33bef 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.cpp +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.cpp @@ -1,33 +1,32 @@ /*=================================================================== 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 "org_mitk_gui_qt_classificationsegmentation_Activator.h" -#include "ClassificationSegmentation.h" +#include "mitkPreprocessingResamplingActivator.h" +#include "QmitkPreprocessingResamplingView.h" namespace mitk { -void org_mitk_gui_qt_classificationsegmentation_Activator::start(ctkPluginContext* context) +void PreprocessingResamplingActivator::start(ctkPluginContext* context) { - BERRY_REGISTER_EXTENSION_CLASS(ClassificationSegmentation, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkPreprocessingResampling, context) } -void org_mitk_gui_qt_classificationsegmentation_Activator::stop(ctkPluginContext* context) +void PreprocessingResamplingActivator::stop(ctkPluginContext* context) { Q_UNUSED(context) } } diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.h similarity index 58% copy from Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h copy to Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.h index 02fc27aa6f..c757c5502c 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/org_mitk_gui_qt_classificationsegmentation_Activator.h +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/mitkPreprocessingResamplingActivator.h @@ -1,41 +1,40 @@ /*=================================================================== 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 org_mitk_gui_qt_classificationsegmentation_Activator_h -#define org_mitk_gui_qt_classificationsegmentation_Activator_h +#ifndef MITKBPREPROCESSINGRESAMPLINGACTIVATOR_H +#define MITKBPREPROCESSINGRESAMPLINGACTIVATOR_H #include namespace mitk { -class org_mitk_gui_qt_classificationsegmentation_Activator : +class PreprocessingResamplingActivator : public QObject, public ctkPluginActivator { Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_classificationsegmentation") + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_preprocessing_resampling") Q_INTERFACES(ctkPluginActivator) public: - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; -}; // org_mitk_gui_qt_classificationsegmentation_Activator +}; // basicImageProcessingActivator } -#endif // org_mitk_gui_qt_classificationsegmentation_Activator_h +#endif // MITKBPREPROCESSINGRESAMPLINGACTIVATOR_H