diff --git a/Modules/Segmentation/CMakeLists.txt b/Modules/Segmentation/CMakeLists.txt index 865c34266e..1c31c05044 100644 --- a/Modules/Segmentation/CMakeLists.txt +++ b/Modules/Segmentation/CMakeLists.txt @@ -1,9 +1,9 @@ mitk_create_module( INCLUDE_DIRS Algorithms Controllers DataManagement Interactions Rendering SegmentationUtilities/BooleanOperations SegmentationUtilities/MorphologicalOperations DEPENDS MitkAlgorithmsExt MitkSurfaceInterpolation MitkGraphAlgorithms MitkContourModel MitkMultilabel PACKAGE_DEPENDS PUBLIC ITK|QuadEdgeMesh+RegionGrowing - PRIVATE ITK|LabelMap+Watersheds VTK|ImagingGeneral + PRIVATE ITK|LabelMap+MathematicalMorphology VTK|ImagingGeneral ) add_subdirectory(Testing) diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.cpp deleted file mode 100644 index 86a4afd6bf..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkFastMarchingBaseTool.h" -#include "mitkToolManager.h" - -#include "mitkBaseRenderer.h" -#include "mitkInteractionConst.h" -#include "mitkRenderingManager.h" -#include "mitkInteractionPositionEvent.h" - -#include "mitkImageAccessByItk.h" - -#include "mitkSegTool2D.h" - -#include - -// itk filter -#include "itkBinaryThresholdImageFilter.h" -#include "itkCurvatureAnisotropicDiffusionImageFilter.h" -#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" -#include "itkSigmoidImageFilter.h" -#include "itkFastMarchingImageFilter.h" - -// us -#include -#include -#include -#include - - -mitk::FastMarchingBaseTool::FastMarchingBaseTool(unsigned int toolDim) - : AutoSegmentationWithPreviewTool(false, "FastMarchingTool"), - m_LowerThreshold(0), - m_UpperThreshold(200), - m_StoppingValue(100), - m_Sigma(1.0), - m_Alpha(-0.5), - m_Beta(3.0), - m_ToolDimension(toolDim) -{ -} - -mitk::FastMarchingBaseTool::~FastMarchingBaseTool() -{ -} - -bool mitk::FastMarchingBaseTool::CanHandle(const BaseData* referenceData, const BaseData* workingData) const -{ - if(!Superclass::CanHandle(referenceData, workingData)) - return false; - - if (referenceData == nullptr) - return false; - - auto *image = dynamic_cast(referenceData); - - if (image == nullptr) - return false; - - if (image->GetDimension() < 3) - return false; - - return true; -} - -const char **mitk::FastMarchingBaseTool::GetXPM() const -{ - return nullptr; // mitkFastMarchingBaseTool_xpm; -} - -us::ModuleResource mitk::FastMarchingBaseTool::GetIconResource() const -{ - us::Module *module = us::GetModuleContext()->GetModule(); - us::ModuleResource resource = module->GetResource("FastMarching_48x48.png"); - return resource; -} - -us::ModuleResource mitk::FastMarchingBaseTool::GetCursorIconResource() const -{ - us::Module* module = us::GetModuleContext()->GetModule(); - us::ModuleResource resource = module->GetResource("FastMarching_Cursor_32x32.png"); - return resource; -} - -void mitk::FastMarchingBaseTool::SetUpperThreshold(double value) -{ - m_UpperThreshold = value / 10.0; -} - -void mitk::FastMarchingBaseTool::SetLowerThreshold(double value) -{ - m_LowerThreshold = value / 10.0; -} - -void mitk::FastMarchingBaseTool::SetBeta(double value) -{ - if (m_Beta != value) - { - m_Beta = value; - } -} - -void mitk::FastMarchingBaseTool::SetSigma(double value) -{ - if (m_Sigma != value) - { - if (value > 0.0) - { - m_Sigma = value; - } - } -} - -void mitk::FastMarchingBaseTool::SetAlpha(double value) -{ - if (m_Alpha != value) - { - m_Alpha = value; - } -} - -void mitk::FastMarchingBaseTool::SetStoppingValue(double value) -{ - if (m_StoppingValue != value) - { - m_StoppingValue = value; - } -} - -void mitk::FastMarchingBaseTool::Activated() -{ - Superclass::Activated(); - - m_SeedsAsPointSet = PointSet::New(); - //ensure that the seed points are visible for all timepoints. - dynamic_cast(m_SeedsAsPointSet->GetTimeGeometry())->SetStepDuration(std::numeric_limits::max()); - - m_SeedsAsPointSetNode = DataNode::New(); - m_SeedsAsPointSetNode->SetData(m_SeedsAsPointSet); - m_SeedsAsPointSetNode->SetName(std::string(this->GetName()) + "_PointSet"); - m_SeedsAsPointSetNode->SetBoolProperty("helper object", true); - m_SeedsAsPointSetNode->SetColor(0.0, 1.0, 0.0); - m_SeedsAsPointSetNode->SetVisibility(true); - - this->GetDataStorage()->Add(m_SeedsAsPointSetNode, this->GetToolManager()->GetWorkingData(0)); -} - -void mitk::FastMarchingBaseTool::Deactivated() -{ - this->ClearSeeds(); - - this->GetDataStorage()->Remove(m_SeedsAsPointSetNode); - m_SeedsAsPointSetNode = nullptr; - m_SeedsAsPointSet = nullptr; - - Superclass::Deactivated(); -} - - -void mitk::FastMarchingBaseTool::ClearSeeds() -{ - if (this->m_SeedsAsPointSet.IsNotNull()) - { - // renew pointset - this->m_SeedsAsPointSet = PointSet::New(); - //ensure that the seed points are visible for all timepoints. - dynamic_cast(m_SeedsAsPointSet->GetTimeGeometry())->SetStepDuration(std::numeric_limits::max()); - this->m_SeedsAsPointSetNode->SetData(this->m_SeedsAsPointSet); - } -} - -void mitk::FastMarchingBaseTool::ConnectActionsAndFunctions() -{ - CONNECT_FUNCTION("ShiftSecondaryButtonPressed", OnAddPoint); - CONNECT_FUNCTION("ShiftPrimaryButtonPressed", OnAddPoint); - CONNECT_FUNCTION("DeletePoint", OnDelete); -} - -void mitk::FastMarchingBaseTool::OnAddPoint(StateMachineAction*, InteractionEvent* interactionEvent) -{ - if (!this->IsUpdating() && m_SeedsAsPointSet.IsNotNull()) - { - const auto positionEvent = dynamic_cast(interactionEvent); - - if (positionEvent != nullptr) - { - auto workingPlaneGeometry = positionEvent->GetSender()->GetCurrentWorldPlaneGeometry(); - - // if click was on another plane and we are in 2D mode we should reset the seeds - if (m_ToolDimension == 2 && ( nullptr == this->GetWorkingPlaneGeometry() || !this->GetWorkingPlaneGeometry()->IsOnPlane(workingPlaneGeometry))) - { - this->ClearSeeds(); - this->SetWorkingPlaneGeometry(workingPlaneGeometry->Clone()); - } - - m_SeedsAsPointSet->InsertPoint(m_SeedsAsPointSet->GetSize(), positionEvent->GetPositionInWorld()); - this->UpdatePreview(); - } - } -} - -void mitk::FastMarchingBaseTool::OnDelete(StateMachineAction*, InteractionEvent* /*interactionEvent*/) -{ - if (!this->IsUpdating() && m_SeedsAsPointSet.IsNotNull()) - { - // delete last seed point - if (this->m_SeedsAsPointSet->GetSize() > 0) - { - m_SeedsAsPointSet->RemovePointAtEnd(0); - this->UpdatePreview(); - } - } -} - -void mitk::FastMarchingBaseTool::DoUpdatePreview(const Image* inputAtTimeStep, const Image* /*oldSegAtTimeStep*/, Image* previewImage, TimeStepType timeStep) -{ - if (nullptr != inputAtTimeStep && nullptr != previewImage && m_SeedsAsPointSet.IsNotNull() && m_SeedsAsPointSet->GetSize() > 0) - { - if (nullptr == this->GetWorkingPlaneGeometry()) - { - AccessFixedDimensionByItk_n(inputAtTimeStep, ITKFastMarching, 3, - (previewImage, timeStep, inputAtTimeStep->GetGeometry())); - } - else - { - AccessFixedDimensionByItk_n(inputAtTimeStep, ITKFastMarching, 2, - (previewImage, timeStep, inputAtTimeStep->GetGeometry())); - } - } -} - -template -void mitk::FastMarchingBaseTool::ITKFastMarching(const itk::Image* inputImage, - Image* segmentation, - unsigned int timeStep, - const BaseGeometry* inputGeometry) -{ - // typedefs for itk pipeline - typedef itk::Image InputImageType; - - typedef float InternalPixelType; - typedef itk::Image InternalImageType; - - typedef Tool::DefaultSegmentationDataType OutputPixelType; - typedef itk::Image OutputImageType; - - typedef itk::CurvatureAnisotropicDiffusionImageFilter SmoothingFilterType; - typedef itk::GradientMagnitudeRecursiveGaussianImageFilter GradientFilterType; - typedef itk::SigmoidImageFilter SigmoidFilterType; - typedef itk::BinaryThresholdImageFilter ThresholdingFilterType; - - typedef itk::FastMarchingImageFilter FastMarchingFilterType; - typedef typename FastMarchingFilterType::NodeContainer NodeContainer; - typedef typename FastMarchingFilterType::NodeType NodeType; - - //convert point set seed into trialpoint - typename NodeContainer::Pointer trialPoints = NodeContainer::New(); - trialPoints->Initialize(); - - for (auto pos = m_SeedsAsPointSet->Begin(); pos != m_SeedsAsPointSet->End(); ++pos) - { - Point3D clickInIndex; - - inputGeometry->WorldToIndex(pos->Value(), clickInIndex); - itk::Index seedPosition; - for (unsigned int dim = 0; dim < VImageDimension; ++dim) - { - seedPosition[dim] = clickInIndex[dim]; - } - - NodeType node; - const double seedValue = 0.0; - node.SetValue(seedValue); - node.SetIndex(seedPosition); - trialPoints->InsertElement(trialPoints->Size(), node); - } - - // assemble pipeline - auto smoothFilter = SmoothingFilterType::New(); - smoothFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - smoothFilter->SetTimeStep(0.05); - smoothFilter->SetNumberOfIterations(2); - smoothFilter->SetConductanceParameter(9.0); - - auto gradientMagnitudeFilter = GradientFilterType::New(); - gradientMagnitudeFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - gradientMagnitudeFilter->SetSigma(m_Sigma); - - auto sigmoidFilter = SigmoidFilterType::New(); - sigmoidFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - sigmoidFilter->SetAlpha(m_Alpha); - sigmoidFilter->SetBeta(m_Beta); - sigmoidFilter->SetOutputMinimum(0.0); - sigmoidFilter->SetOutputMaximum(1.0); - - auto fastMarchingFilter = FastMarchingFilterType::New(); - fastMarchingFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - fastMarchingFilter->SetStoppingValue(m_StoppingValue); - fastMarchingFilter->SetTrialPoints(trialPoints); - - auto thresholdFilter = ThresholdingFilterType::New(); - thresholdFilter->SetLowerThreshold(m_LowerThreshold); - thresholdFilter->SetUpperThreshold(m_UpperThreshold); - thresholdFilter->SetInsideValue(this->GetUserDefinedActiveLabel()); - thresholdFilter->SetOutsideValue(0); - - // set up pipeline - smoothFilter->SetInput(inputImage); - gradientMagnitudeFilter->SetInput(smoothFilter->GetOutput()); - sigmoidFilter->SetInput(gradientMagnitudeFilter->GetOutput()); - fastMarchingFilter->SetInput(sigmoidFilter->GetOutput()); - thresholdFilter->SetInput(fastMarchingFilter->GetOutput()); - thresholdFilter->Update(); - - if (nullptr == this->GetWorkingPlaneGeometry()) - { - segmentation->SetVolume((void*)(thresholdFilter->GetOutput()->GetPixelContainer()->GetBufferPointer()), timeStep); - } - else - { - Image::Pointer sliceImage = Image::New(); - CastToMitkImage(thresholdFilter->GetOutput(), sliceImage); - SegTool2D::WriteSliceToVolume(segmentation, this->GetWorkingPlaneGeometry(), sliceImage, timeStep, false); - } -} diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.h b/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.h deleted file mode 100644 index 93d5bb0d61..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingBaseTool.h +++ /dev/null @@ -1,117 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkFastMarchingBaseTool_h_Included -#define mitkFastMarchingBaseTool_h_Included - -#include "mitkAutoSegmentationWithPreviewTool.h" -#include "mitkDataNode.h" -#include "mitkPointSet.h" -#include "mitkPointSetDataInteractor.h" -#include "mitkToolCommand.h" - -#include "itkImage.h" - -#include - -namespace us -{ - class ModuleResource; -} - -namespace mitk -{ - /** - \brief FastMarching semgentation tool base class. - - The segmentation is done by setting one or more seed points on the image - and adapting the time range and threshold. The pipeline is: - Smoothing->GradientMagnitude->SigmoidFunction->FastMarching->Threshold - The resulting binary image is seen as a segmentation of an object. - - For detailed documentation see ITK Software Guide section 9.3.1 Fast Marching Segmentation. - */ - class MITKSEGMENTATION_EXPORT FastMarchingBaseTool : public AutoSegmentationWithPreviewTool - { - public: - mitkClassMacro(FastMarchingBaseTool, AutoSegmentationWithPreviewTool); - - bool CanHandle(const BaseData* referenceData, const BaseData* workingData) const override; - - /* icon stuff */ - const char **GetXPM() const override; - us::ModuleResource GetCursorIconResource() const override; - us::ModuleResource GetIconResource() const override; - - void Activated() override; - void Deactivated() override; - - /// \brief Set parameter used in Threshold filter. - void SetUpperThreshold(double); - - /// \brief Set parameter used in Threshold filter. - void SetLowerThreshold(double); - - /// \brief Set parameter used in Fast Marching filter. - void SetStoppingValue(double); - - /// \brief Set parameter used in Gradient Magnitude filter. - void SetSigma(double); - - /// \brief Set parameter used in Fast Marching filter. - void SetAlpha(double); - - /// \brief Set parameter used in Fast Marching filter. - void SetBeta(double); - - /// \brief Clear all seed points. - void ClearSeeds(); - - - protected: - FastMarchingBaseTool(unsigned int toolDim); - ~FastMarchingBaseTool() override; - - void ConnectActionsAndFunctions() override; - - /// \brief Add point action of StateMachine pattern - virtual void OnAddPoint(StateMachineAction*, InteractionEvent* interactionEvent); - - /// \brief Delete action of StateMachine pattern - virtual void OnDelete(StateMachineAction*, InteractionEvent* interactionEvent); - - void DoUpdatePreview(const Image* inputAtTimeStep, const Image* oldSegAtTimeStep, Image* previewImage, TimeStepType timeStep) override; - - template - void ITKFastMarching(const itk::Image* inputImage, - Image* segmentation, unsigned int timeStep, const BaseGeometry* inputGeometry); - - private: - float m_LowerThreshold; // used in Threshold filter - float m_UpperThreshold; // used in Threshold filter - float m_StoppingValue; // used in Fast Marching filter - float m_Sigma; // used in GradientMagnitude filter - float m_Alpha; // used in Sigmoid filter - float m_Beta; // used in Sigmoid filter - - DataNode::Pointer m_SeedsAsPointSetNode; // used to visualize the seed points - PointSet::Pointer m_SeedsAsPointSet; - - /** Indicating if the tool is used in 2D mode (just segment the current slice) - * or 3D mode (segment the whole current volume),*/ - unsigned int m_ToolDimension; - - }; - -} // namespace - -#endif diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp deleted file mode 100644 index c4a58520e0..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkFastMarchingTool.h" - - -namespace mitk -{ - MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, FastMarchingTool, "FastMarching tool"); -} - -mitk::FastMarchingTool::FastMarchingTool() - : FastMarchingBaseTool(2) -{ -} - -mitk::FastMarchingTool::~FastMarchingTool() -{ -} - -const char *mitk::FastMarchingTool::GetName() const -{ - return "Fast Marching"; -} - diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool.h b/Modules/Segmentation/Interactions/mitkFastMarchingTool.h deleted file mode 100644 index 9aa06c0b1a..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool.h +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkFastMarchingTool_h_Included -#define mitkFastMarchingTool_h_Included - -#include "mitkFastMarchingBaseTool.h" - -#include - -namespace mitk -{ - /** - \brief FastMarching semgentation tool. - - The segmentation is done by setting one or more seed points on the image - and adapting the time range and threshold. The pipeline is: - Smoothing->GradientMagnitude->SigmoidFunction->FastMarching->Threshold - The resulting binary image is seen as a segmentation of an object. - - For detailed documentation see ITK Software Guide section 9.3.1 Fast Marching Segmentation. - */ - class MITKSEGMENTATION_EXPORT FastMarchingTool : public FastMarchingBaseTool - { - public: - mitkClassMacro(FastMarchingTool, FastMarchingBaseTool); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - - const char *GetName() const override; - - protected: - FastMarchingTool(); - ~FastMarchingTool() override; - }; - -} // namespace - -#endif diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool.xpm b/Modules/Segmentation/Interactions/mitkFastMarchingTool.xpm deleted file mode 100644 index ee5b02c0bd..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool.xpm +++ /dev/null @@ -1,53 +0,0 @@ -/* XPM */ -static const char * mitkFastMarchingTool_xpm[] = { -"48 48 2 1", -" c None", -". c #000000", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ...... ", -" .......... ", -" ........... ", -" ... ..... ", -" . ... ", -" ... ", -" ... ", -" ... ", -" ... ", -" .... ", -" .... ", -" ..... ", -" .... ", -" ... ", -" ... ", -" ... ", -" ", -" ", -" ", -" ... ", -" ... ", -" ... ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp deleted file mode 100644 index 0de2aacf30..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkFastMarchingTool3D.h" - -namespace mitk -{ - MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, FastMarchingTool3D, "FastMarching3D tool"); -} - -mitk::FastMarchingTool3D::FastMarchingTool3D() - : FastMarchingBaseTool(3) -{ -} - -mitk::FastMarchingTool3D::~FastMarchingTool3D() -{ -} - -const char *mitk::FastMarchingTool3D::GetName() const -{ - return "Fast Marching 3D"; -} diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h deleted file mode 100644 index 88b82a6038..0000000000 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkFastMarchingTool3D_h_Included -#define mitkFastMarchingTool3D_h_Included - -#include "mitkFastMarchingBaseTool.h" - -#include - -namespace mitk -{ - /** - \brief FastMarching semgentation tool. - - The segmentation is done by setting one or more seed points on the image - and adapting the time range and threshold. The pipeline is: - Smoothing->GradientMagnitude->SigmoidFunction->FastMarching->Threshold - The resulting binary image is seen as a segmentation of an object. - - For detailed documentation see ITK Software Guide section 9.3.1 Fast Marching Segmentation. - */ - class MITKSEGMENTATION_EXPORT FastMarchingTool3D : public FastMarchingBaseTool - { - public: - mitkClassMacro(FastMarchingTool3D, FastMarchingBaseTool); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - - /* icon stuff */ - const char *GetName() const override; - - protected: - FastMarchingTool3D(); - ~FastMarchingTool3D() override; - }; - -} // namespace - -#endif diff --git a/Modules/Segmentation/Interactions/mitkWatershedTool.cpp b/Modules/Segmentation/Interactions/mitkWatershedTool.cpp deleted file mode 100644 index 358cade477..0000000000 --- a/Modules/Segmentation/Interactions/mitkWatershedTool.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkWatershedTool.h" - -#include "mitkIOUtil.h" -#include "mitkITKImageImport.h" -#include "mitkImage.h" -#include "mitkLabelSetImage.h" -#include "mitkImageAccessByItk.h" -#include "mitkImageCast.h" -#include "mitkImageStatisticsHolder.h" -#include "mitkLevelWindowManager.h" -#include "mitkLookupTable.h" -#include "mitkLookupTableProperty.h" -#include "mitkProgressBar.h" -#include "mitkRenderingManager.h" -#include "mitkRenderingModeProperty.h" -#include "mitkToolCommand.h" -#include "mitkToolManager.h" -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -namespace mitk -{ - MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, WatershedTool, "Watershed tool"); -} - - -void mitk::WatershedTool::Activated() -{ - Superclass::Activated(); - - m_Level = 0.0; - m_Threshold = 0.0; - - m_MagFilter = nullptr; - m_WatershedFilter = nullptr; - m_LastFilterInput = nullptr; -} - -us::ModuleResource mitk::WatershedTool::GetIconResource() const -{ - us::Module *module = us::GetModuleContext()->GetModule(); - us::ModuleResource resource = module->GetResource("Watershed_48x48.png"); - return resource; -} - -const char **mitk::WatershedTool::GetXPM() const -{ - return nullptr; -} - -const char *mitk::WatershedTool::GetName() const -{ - return "Watershed"; -} - -mitk::LabelSetImage::Pointer mitk::WatershedTool::ComputeMLPreview(const Image* inputAtTimeStep, TimeStepType /*timeStep*/) -{ - mitk::LabelSetImage::Pointer labelSetOutput; - - try - { - mitk::Image::Pointer output; - bool inputChanged = inputAtTimeStep != m_LastFilterInput; - // create and run itk filter pipeline - AccessByItk_2(inputAtTimeStep, ITKWatershed, output, inputChanged); - - labelSetOutput = mitk::LabelSetImage::New(); - labelSetOutput->InitializeByLabeledImage(output); - } - catch (itk::ExceptionObject & e) - { - //force reset of filters as they might be in an invalid state now. - m_MagFilter = nullptr; - m_WatershedFilter = nullptr; - m_LastFilterInput = nullptr; - - MITK_ERROR << "Watershed Filter Error: " << e.GetDescription(); - } - - m_LastFilterInput = inputAtTimeStep; - - return labelSetOutput; -} - -template -void mitk::WatershedTool::ITKWatershed(const itk::Image* originalImage, - mitk::Image::Pointer& segmentation, bool inputChanged) -{ - typedef itk::WatershedImageFilter> WatershedFilter; - typedef itk::GradientMagnitudeRecursiveGaussianImageFilter, - itk::Image> - MagnitudeFilter; - - // We create the filter pipeline only once (if needed) and not everytime we - // generate the ml image preview. - // Reason: If only the levels are changed the update of the pipe line is very - // fast and we want to profit from this feature. - - // at first add a gradient magnitude filter - typename MagnitudeFilter::Pointer magnitude = dynamic_cast(m_MagFilter.GetPointer()); - if (magnitude.IsNull()) - { - magnitude = MagnitudeFilter::New(); - magnitude->SetSigma(1.0); - magnitude->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - m_MagFilter = magnitude.GetPointer(); - } - - if (inputChanged) - { - magnitude->SetInput(originalImage); - } - - // then add the watershed filter to the pipeline - typename WatershedFilter::Pointer watershed = dynamic_cast(m_WatershedFilter.GetPointer()); - if (watershed.IsNull()) - { - watershed = WatershedFilter::New(); - watershed->SetInput(magnitude->GetOutput()); - watershed->AddObserver(itk::ProgressEvent(), m_ProgressCommand); - m_WatershedFilter = watershed.GetPointer(); - } - - watershed->SetThreshold(m_Threshold); - watershed->SetLevel(m_Level); - watershed->Update(); - - // then make sure, that the output has the desired pixel type - typedef itk::CastImageFilter> - CastFilter; - typename CastFilter::Pointer cast = CastFilter::New(); - cast->SetInput(watershed->GetOutput()); - - // start the whole pipeline - cast->Update(); - - // since we obtain a new image from our pipeline, we have to make sure, that our mitk::Image::Pointer - // is responsible for the memory management of the output image - segmentation = mitk::GrabItkImageMemory(cast->GetOutput()); -} diff --git a/Modules/Segmentation/Interactions/mitkWatershedTool.h b/Modules/Segmentation/Interactions/mitkWatershedTool.h deleted file mode 100644 index a4bea005ec..0000000000 --- a/Modules/Segmentation/Interactions/mitkWatershedTool.h +++ /dev/null @@ -1,84 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef mitkWatershedTool_h_Included -#define mitkWatershedTool_h_Included - -#include "mitkAutoMLSegmentationWithPreviewTool.h" -#include "mitkCommon.h" -#include - -namespace us -{ - class ModuleResource; -} - -namespace mitk -{ - /** - \brief Simple watershed segmentation tool. - - \ingroup Interaction - \ingroup ToolManagerEtAl - - Wraps ITK Watershed Filter into tool concept of MITK. For more information look into ITK documentation. - - \warning Only to be instantiated by mitk::ToolManager. - */ - class MITKSEGMENTATION_EXPORT WatershedTool : public AutoMLSegmentationWithPreviewTool - { - public: - mitkClassMacro(WatershedTool, AutoMLSegmentationWithPreviewTool); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - - const char** GetXPM() const override; - const char* GetName() const override; - us::ModuleResource GetIconResource() const override; - - void Activated() override; - - itkSetMacro(Threshold, double); - itkGetConstMacro(Threshold, double); - - itkSetMacro(Level, double); - itkGetConstMacro(Level, double); - - protected: - WatershedTool() = default; - ~WatershedTool() = default; - - LabelSetImage::Pointer ComputeMLPreview(const Image* inputAtTimeStep, TimeStepType timeStep) override; - - /** \brief Threshold parameter of the ITK Watershed Image Filter. See ITK Documentation for more information. */ - double m_Threshold = 0.0; - /** \brief Threshold parameter of the ITK Watershed Image Filter. See ITK Documentation for more information. */ - double m_Level = 0.0; - -private: - /** \brief Creates and runs an ITK filter pipeline consisting of the filters: GradientMagnitude-, Watershed- and - * CastImageFilter. - * - * \param originalImage The input image, which is delivered by the AccessByItk macro. - * \param segmentation A pointer to the output image, which will point to the pipeline output after execution. - */ - template - void ITKWatershed(const itk::Image* originalImage, itk::SmartPointer& segmentation, bool inputChanged); - - itk::ProcessObject::Pointer m_MagFilter; - itk::ProcessObject::Pointer m_WatershedFilter; - mitk::Image::ConstPointer m_LastFilterInput; - }; - -} // namespace - -#endif diff --git a/Modules/Segmentation/Resources/FastMarching_48x48.png b/Modules/Segmentation/Resources/FastMarching_48x48.png deleted file mode 100644 index e67f7a2a75..0000000000 Binary files a/Modules/Segmentation/Resources/FastMarching_48x48.png and /dev/null differ diff --git a/Modules/Segmentation/Resources/FastMarching_Cursor_32x32.png b/Modules/Segmentation/Resources/FastMarching_Cursor_32x32.png deleted file mode 100644 index 12bddbaa4b..0000000000 Binary files a/Modules/Segmentation/Resources/FastMarching_Cursor_32x32.png and /dev/null differ diff --git a/Modules/Segmentation/Resources/Interactions/FastMarchingTool.xml b/Modules/Segmentation/Resources/Interactions/FastMarchingTool.xml deleted file mode 100644 index 1baf80a04b..0000000000 --- a/Modules/Segmentation/Resources/Interactions/FastMarchingTool.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Modules/Segmentation/Resources/Interactions/PickingTool.xml b/Modules/Segmentation/Resources/Interactions/PickingTool.xml index 1baf80a04b..c87c5441c2 100644 --- a/Modules/Segmentation/Resources/Interactions/PickingTool.xml +++ b/Modules/Segmentation/Resources/Interactions/PickingTool.xml @@ -1,19 +1,19 @@ - + - \ No newline at end of file + diff --git a/Modules/Segmentation/Resources/Watershed_48x48.png b/Modules/Segmentation/Resources/Watershed_48x48.png deleted file mode 100644 index 39641b42ec..0000000000 Binary files a/Modules/Segmentation/Resources/Watershed_48x48.png and /dev/null differ diff --git a/Modules/Segmentation/Resources/Watershed_Cursor_32x32.png b/Modules/Segmentation/Resources/Watershed_Cursor_32x32.png deleted file mode 100644 index 2d88f7f780..0000000000 Binary files a/Modules/Segmentation/Resources/Watershed_Cursor_32x32.png and /dev/null differ diff --git a/Modules/Segmentation/files.cmake b/Modules/Segmentation/files.cmake index b1f29f073e..e8f1ecffb7 100644 --- a/Modules/Segmentation/files.cmake +++ b/Modules/Segmentation/files.cmake @@ -1,119 +1,110 @@ set(CPP_FILES Algorithms/mitkCalculateSegmentationVolume.cpp Algorithms/mitkContourModelSetToImageFilter.cpp Algorithms/mitkContourSetToPointSetFilter.cpp Algorithms/mitkContourUtils.cpp Algorithms/mitkCorrectorAlgorithm.cpp Algorithms/mitkDiffImageApplier.cpp Algorithms/mitkDiffSliceOperation.cpp Algorithms/mitkDiffSliceOperationApplier.cpp Algorithms/mitkFeatureBasedEdgeDetectionFilter.cpp Algorithms/mitkImageLiveWireContourModelFilter.cpp Algorithms/mitkImageToContourFilter.cpp #Algorithms/mitkImageToContourModelFilter.cpp Algorithms/mitkImageToLiveWireContourFilter.cpp Algorithms/mitkManualSegmentationToSurfaceFilter.cpp Algorithms/mitkOtsuSegmentationFilter.cpp Algorithms/mitkSegmentationObjectFactory.cpp Algorithms/mitkShapeBasedInterpolationAlgorithm.cpp Algorithms/mitkShowSegmentationAsSmoothedSurface.cpp Algorithms/mitkShowSegmentationAsSurface.cpp Algorithms/mitkVtkImageOverwrite.cpp Controllers/mitkSegmentationInterpolationController.cpp Controllers/mitkToolManager.cpp Controllers/mitkSegmentationModuleActivator.cpp Controllers/mitkToolManagerProvider.cpp DataManagement/mitkContour.cpp DataManagement/mitkContourSet.cpp DataManagement/mitkExtrudedContour.cpp Interactions/mitkAdaptiveRegionGrowingTool.cpp Interactions/mitkAddContourTool.cpp Interactions/mitkAutoCropTool.cpp Interactions/mitkAutoSegmentationTool.cpp Interactions/mitkAutoSegmentationWithPreviewTool.cpp Interactions/mitkAutoMLSegmentationWithPreviewTool.cpp Interactions/mitkBinaryThresholdBaseTool.cpp Interactions/mitkBinaryThresholdTool.cpp Interactions/mitkBinaryThresholdULTool.cpp Interactions/mitkCalculateGrayValueStatisticsTool.cpp Interactions/mitkCalculateVolumetryTool.cpp Interactions/mitkContourModelInteractor.cpp Interactions/mitkContourModelLiveWireInteractor.cpp Interactions/mitkLiveWireTool2D.cpp Interactions/mitkContourTool.cpp Interactions/mitkCreateSurfaceTool.cpp Interactions/mitkDrawPaintbrushTool.cpp Interactions/mitkErasePaintbrushTool.cpp Interactions/mitkEraseRegionTool.cpp - Interactions/mitkFastMarchingBaseTool.cpp - Interactions/mitkFastMarchingTool.cpp - Interactions/mitkFastMarchingTool3D.cpp Interactions/mitkFeedbackContourTool.cpp Interactions/mitkFillRegionTool.cpp Interactions/mitkOtsuTool3D.cpp Interactions/mitkPaintbrushTool.cpp Interactions/mitkPixelManipulationTool.cpp Interactions/mitkRegionGrowingTool.cpp Interactions/mitkSegmentationsProcessingTool.cpp Interactions/mitkSetRegionTool.cpp Interactions/mitkSegTool2D.cpp Interactions/mitkSubtractContourTool.cpp Interactions/mitkTool.cpp Interactions/mitkToolCommand.cpp - Interactions/mitkWatershedTool.cpp Interactions/mitkPickingTool.cpp Interactions/mitknnUnetTool.cpp Interactions/mitkSegmentationInteractor.cpp #SO Interactions/mitkProcessExecutor.cpp Rendering/mitkContourMapper2D.cpp Rendering/mitkContourSetMapper2D.cpp Rendering/mitkContourSetVtkMapper3D.cpp Rendering/mitkContourVtkMapper3D.cpp SegmentationUtilities/BooleanOperations/mitkBooleanOperation.cpp SegmentationUtilities/MorphologicalOperations/mitkMorphologicalOperations.cpp #Added from ML Controllers/mitkSliceBasedInterpolationController.cpp Algorithms/mitkSurfaceStampImageFilter.cpp ) set(RESOURCE_FILES Add_48x48.png Add_Cursor_32x32.png AI_48x48.png AI_Cursor_32x32.png Erase_48x48.png Erase_Cursor_32x32.png - FastMarching_48x48.png - FastMarching_Cursor_32x32.png Fill_48x48.png Fill_Cursor_32x32.png LiveWire_48x48.png LiveWire_Cursor_32x32.png Otsu_48x48.png Paint_48x48.png Paint_Cursor_32x32.png Pick_48x48.png RegionGrowing_48x48.png RegionGrowing_Cursor_32x32.png Subtract_48x48.png Subtract_Cursor_32x32.png Threshold_48x48.png TwoThresholds_48x48.png - Watershed_48x48.png - Watershed_Cursor_32x32.png Wipe_48x48.png Wipe_Cursor_32x32.png Interactions/dummy.xml Interactions/LiveWireTool.xml - Interactions/FastMarchingTool.xml Interactions/PickingTool.xml Interactions/PressMoveRelease.xml Interactions/PressMoveReleaseAndPointSetting.xml Interactions/PressMoveReleaseWithCTRLInversion.xml Interactions/PressMoveReleaseWithCTRLInversionAllMouseMoves.xml Interactions/SegmentationToolsConfig.xml Interactions/ContourModelModificationConfig.xml Interactions/ContourModelModificationInteractor.xml ) diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp deleted file mode 100644 index 165cd8bde0..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFastMarchingTool3DGUI.h" - -MITK_TOOL_GUI_MACRO(MITKSEGMENTATIONUI_EXPORT, QmitkFastMarchingTool3DGUI, "") - -QmitkFastMarchingTool3DGUI::QmitkFastMarchingTool3DGUI() : QmitkFastMarchingToolGUIBase(false) -{ -} - diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h deleted file mode 100644 index 42f2c60ecb..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QmitkFastMarchingTool3DGUI_h_Included -#define QmitkFastMarchingTool3DGUI_h_Included - -#include "QmitkFastMarchingToolGUIBase.h" -#include - -/** -\ingroup org_mitk_gui_qt_interactivesegmentation_internal -\brief GUI for mitk::FastMarchingTool3D. -\sa mitk::FastMarchingTool -*/ -class MITKSEGMENTATIONUI_EXPORT QmitkFastMarchingTool3DGUI : public QmitkFastMarchingToolGUIBase -{ - Q_OBJECT - -public: - mitkClassMacro(QmitkFastMarchingTool3DGUI, QmitkFastMarchingToolGUIBase); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - -protected: - QmitkFastMarchingTool3DGUI(); - ~QmitkFastMarchingTool3DGUI() = default; -}; - -#endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp deleted file mode 100644 index d37040dc8b..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFastMarchingToolGUI.h" - -#include "mitkBaseRenderer.h" -#include "mitkStepper.h" -#include -#include -#include -#include -#include -#include -#include -#include - -MITK_TOOL_GUI_MACRO(MITKSEGMENTATIONUI_EXPORT, QmitkFastMarchingToolGUI, "") - -QmitkFastMarchingToolGUI::QmitkFastMarchingToolGUI() : QmitkFastMarchingToolGUIBase(true) -{} diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h deleted file mode 100644 index 72340f6114..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QmitkFastMarchingToolGUI_h_Included -#define QmitkFastMarchingToolGUI_h_Included - -#include "QmitkFastMarchingToolGUIBase.h" -#include - -/** -\ingroup org_mitk_gui_qt_interactivesegmentation_internal -\brief GUI for mitk::FastMarchingTool in 2D. -\sa mitk::FastMarchingTool -*/ -class MITKSEGMENTATIONUI_EXPORT QmitkFastMarchingToolGUI : public QmitkFastMarchingToolGUIBase -{ - Q_OBJECT - -public: - mitkClassMacro(QmitkFastMarchingToolGUI, QmitkFastMarchingToolGUIBase); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - -protected: - QmitkFastMarchingToolGUI(); - ~QmitkFastMarchingToolGUI() = default; -}; - -#endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.cpp deleted file mode 100644 index 1bd272c0f5..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFastMarchingToolGUIBase.h" - -#include "mitkBaseRenderer.h" -#include "mitkStepper.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QmitkFastMarchingToolGUIBase::QmitkFastMarchingToolGUIBase(bool mode2D) : QmitkAutoSegmentationToolGUIBase(mode2D) -{ -} - -QmitkFastMarchingToolGUIBase::~QmitkFastMarchingToolGUIBase() -{ -} - -void QmitkFastMarchingToolGUIBase::Update() -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetLowerThreshold(m_slwThreshold->minimumValue()); - tool->SetUpperThreshold(m_slwThreshold->maximumValue()); - tool->SetStoppingValue(m_slStoppingValue->value()); - tool->SetSigma(m_slSigma->value()); - tool->SetAlpha(m_slAlpha->value()); - tool->SetBeta(m_slBeta->value()); - tool->UpdatePreview(); - } -} - -void QmitkFastMarchingToolGUIBase::OnThresholdChanged(double lower, double upper) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetLowerThreshold(lower); - tool->SetUpperThreshold(upper); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::OnBetaChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetBeta(value); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::OnSigmaChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetSigma(value); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::OnAlphaChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetAlpha(value); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::OnStoppingValueChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetStoppingValue(value); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::OnClearSeeds() -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->ClearSeeds(); - this->EnableWidgets(false); - this->Update(); - } -} - -void QmitkFastMarchingToolGUIBase::ConnectNewTool(mitk::AutoSegmentationWithPreviewTool* newTool) -{ - Superclass::ConnectNewTool(newTool); - - auto tool = dynamic_cast(newTool); - if (nullptr != tool) - { - tool->SetLowerThreshold(m_slwThreshold->minimumValue()); - tool->SetUpperThreshold(m_slwThreshold->maximumValue()); - tool->SetStoppingValue(m_slStoppingValue->value()); - tool->SetSigma(m_slSigma->value()); - tool->SetAlpha(m_slAlpha->value()); - tool->SetBeta(m_slBeta->value()); - tool->ClearSeeds(); - } -} - -void QmitkFastMarchingToolGUIBase::InitializeUI(QBoxLayout* mainLayout) -{ - mainLayout->setContentsMargins(0, 0, 0, 0); - - QFont fntHelp; - fntHelp.setBold(true); - - QLabel* lblHelp = new QLabel(this); - lblHelp->setText("Press shift-click to add seeds repeatedly."); - lblHelp->setFont(fntHelp); - - mainLayout->addWidget(lblHelp); - - // Sigma controls - { - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setSpacing(2); - - QLabel* lbl = new QLabel(this); - lbl->setText("Sigma: "); - hlayout->addWidget(lbl); - - QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hlayout->addItem(sp2); - - mainLayout->addItem(hlayout); - } - - m_slSigma = new ctkSliderWidget(this); - m_slSigma->setMinimum(0.1); - m_slSigma->setMaximum(5.0); - m_slSigma->setPageStep(0.1); - m_slSigma->setSingleStep(0.01); - m_slSigma->setValue(1.0); - m_slSigma->setTracking(false); - m_slSigma->setToolTip("The \"sigma\" parameter in the Gradient Magnitude filter."); - connect(m_slSigma, SIGNAL(valueChanged(double)), this, SLOT(OnSigmaChanged(double))); - mainLayout->addWidget(m_slSigma); - - // Alpha controls - { - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setSpacing(2); - - QLabel* lbl = new QLabel(this); - lbl->setText("Alpha: "); - hlayout->addWidget(lbl); - - QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hlayout->addItem(sp2); - - mainLayout->addItem(hlayout); - } - - m_slAlpha = new ctkSliderWidget(this); - m_slAlpha->setMinimum(-10); - m_slAlpha->setMaximum(0); - m_slAlpha->setPageStep(0.1); - m_slAlpha->setSingleStep(0.01); - m_slAlpha->setValue(-2.5); - m_slAlpha->setTracking(false); - m_slAlpha->setToolTip("The \"alpha\" parameter in the Sigmoid mapping filter."); - connect(m_slAlpha, SIGNAL(valueChanged(double)), this, SLOT(OnAlphaChanged(double))); - mainLayout->addWidget(m_slAlpha); - - // Beta controls - { - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setSpacing(2); - - QLabel* lbl = new QLabel(this); - lbl->setText("Beta: "); - hlayout->addWidget(lbl); - - QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hlayout->addItem(sp2); - - mainLayout->addLayout(hlayout); - } - - m_slBeta = new ctkSliderWidget(this); - m_slBeta->setMinimum(0); - m_slBeta->setMaximum(100); - m_slBeta->setPageStep(0.1); - m_slBeta->setSingleStep(0.01); - m_slBeta->setValue(3.5); - m_slBeta->setTracking(false); - m_slBeta->setToolTip("The \"beta\" parameter in the Sigmoid mapping filter."); - connect(m_slBeta, SIGNAL(valueChanged(double)), this, SLOT(OnBetaChanged(double))); - mainLayout->addWidget(m_slBeta); - - // stopping value controls - { - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setSpacing(2); - - QLabel* lbl = new QLabel(this); - lbl->setText("Stopping value: "); - hlayout->addWidget(lbl); - - QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hlayout->addItem(sp2); - - mainLayout->addLayout(hlayout); - } - - m_slStoppingValue = new ctkSliderWidget(this); - m_slStoppingValue->setMinimum(0); - m_slStoppingValue->setMaximum(10000); - m_slStoppingValue->setPageStep(10); - m_slStoppingValue->setSingleStep(1); - m_slStoppingValue->setValue(2000); - m_slStoppingValue->setDecimals(0); - m_slStoppingValue->setTracking(false); - m_slStoppingValue->setToolTip("The \"stopping value\" parameter in the fast marching 3D algorithm"); - connect(m_slStoppingValue, SIGNAL(valueChanged(double)), this, SLOT(OnStoppingValueChanged(double))); - mainLayout->addWidget(m_slStoppingValue); - - // threshold controls - { - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setSpacing(2); - - QLabel* lbl = new QLabel(this); - lbl->setText("Threshold: "); - hlayout->addWidget(lbl); - - QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hlayout->addItem(sp2); - - mainLayout->addLayout(hlayout); - } - - m_slwThreshold = new ctkRangeWidget(this); - m_slwThreshold->setMinimum(-100); - m_slwThreshold->setMaximum(5000); - m_slwThreshold->setMinimumValue(-100); - m_slwThreshold->setMaximumValue(2000); - m_slwThreshold->setDecimals(0); - m_slwThreshold->setTracking(false); - m_slwThreshold->setToolTip("The lower and upper thresholds for the final thresholding"); - connect(m_slwThreshold, SIGNAL(valuesChanged(double, double)), this, SLOT(OnThresholdChanged(double, double))); - mainLayout->addWidget(m_slwThreshold); - - m_btClearSeeds = new QPushButton("Clear"); - m_btClearSeeds->setToolTip("Clear current result and start over again"); - m_btClearSeeds->setEnabled(false); - mainLayout->addWidget(m_btClearSeeds); - connect(m_btClearSeeds, SIGNAL(clicked()), this, SLOT(OnClearSeeds())); - - m_slSigma->setDecimals(2); - m_slBeta->setDecimals(2); - m_slAlpha->setDecimals(2); - - this->EnableWidgets(false); - - Superclass::InitializeUI(mainLayout); -} - -void QmitkFastMarchingToolGUIBase::EnableWidgets(bool enable) -{ - Superclass::EnableWidgets(enable); - m_slSigma->setEnabled(enable); - m_slAlpha->setEnabled(enable); - m_slBeta->setEnabled(enable); - m_slStoppingValue->setEnabled(enable); - m_slwThreshold->setEnabled(enable); - m_btClearSeeds->setEnabled(enable); -} diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.h deleted file mode 100644 index 669ef27155..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUIBase.h +++ /dev/null @@ -1,67 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QmitkFastMarchingToolGUIBase_h_Included -#define QmitkFastMarchingToolGUIBase_h_Included - -#include "QmitkAutoSegmentationToolGUIBase.h" -#include "mitkFastMarchingTool3D.h" -#include - -class ctkSliderWidget; -class ctkRangeWidget; -class QPushButton; - -/** -\ingroup org_mitk_gui_qt_interactivesegmentation_internal -\brief Base GUI for mitk::FastMarchingTool (2D and 3D). -\sa mitk::FastMarchingTool -*/ -class MITKSEGMENTATIONUI_EXPORT QmitkFastMarchingToolGUIBase : public QmitkAutoSegmentationToolGUIBase -{ - Q_OBJECT - -public: - mitkClassMacro(QmitkFastMarchingToolGUIBase, QmitkAutoSegmentationToolGUIBase); - -protected slots: - - void OnThresholdChanged(double, double); - void OnAlphaChanged(double); - void OnBetaChanged(double); - void OnSigmaChanged(double); - void OnStoppingValueChanged(double); - void OnClearSeeds(); - -protected: - QmitkFastMarchingToolGUIBase(bool mode2D); - ~QmitkFastMarchingToolGUIBase() override; - - void ConnectNewTool(mitk::AutoSegmentationWithPreviewTool* newTool) override; - void InitializeUI(QBoxLayout* mainLayout) override; - - void EnableWidgets(bool) override; - - void Update(); - - ctkRangeWidget *m_slwThreshold; - ctkSliderWidget *m_slStoppingValue; - ctkSliderWidget *m_slSigma; - ctkSliderWidget *m_slAlpha; - ctkSliderWidget *m_slBeta; - - QPushButton *m_btClearSeeds; - -private: -}; - -#endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp deleted file mode 100644 index fda699f8d4..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkWatershedToolGUI.h" -#include "mitkWatershedTool.h" - -#include - -MITK_TOOL_GUI_MACRO(MITKSEGMENTATIONUI_EXPORT, QmitkWatershedToolGUI, "") - -QmitkWatershedToolGUI::QmitkWatershedToolGUI() : QmitkAutoMLSegmentationToolGUIBase() -{ -} - -void QmitkWatershedToolGUI::ConnectNewTool(mitk::AutoSegmentationWithPreviewTool* newTool) -{ - Superclass::ConnectNewTool(newTool); - - auto tool = dynamic_cast(newTool); - if (nullptr != tool) - { - tool->SetLevel(m_Level); - tool->SetThreshold(m_Threshold); - } - - newTool->IsTimePointChangeAwareOff(); -} - -void QmitkWatershedToolGUI::InitializeUI(QBoxLayout* mainLayout) -{ - m_Controls.setupUi(this); - - m_Controls.thresholdSlider->setMinimum(0); - //We set the threshold maximum to 0.5 to avoid crashes in the watershed filter - //see T27703 for more details. - m_Controls.thresholdSlider->setMaximum(0.5); - m_Controls.thresholdSlider->setValue(m_Threshold); - m_Controls.thresholdSlider->setPageStep(0.01); - m_Controls.thresholdSlider->setSingleStep(0.001); - m_Controls.thresholdSlider->setDecimals(4); - - m_Controls.levelSlider->setMinimum(0); - m_Controls.levelSlider->setMaximum(1); - m_Controls.levelSlider->setValue(m_Level); - m_Controls.levelSlider->setPageStep(0.1); - m_Controls.levelSlider->setSingleStep(0.01); - - connect(m_Controls.previewButton, SIGNAL(clicked()), this, SLOT(OnSettingsAccept())); - connect(m_Controls.levelSlider, SIGNAL(valueChanged(double)), this, SLOT(OnLevelChanged(double))); - connect(m_Controls.thresholdSlider, SIGNAL(valueChanged(double)), this, SLOT(OnThresholdChanged(double))); - - mainLayout->addLayout(m_Controls.verticalLayout); - - Superclass::InitializeUI(mainLayout); -} - -void QmitkWatershedToolGUI::OnSettingsAccept() -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - try - { - m_Threshold = m_Controls.thresholdSlider->value(); - m_Level = m_Controls.levelSlider->value(); - tool->SetThreshold(m_Threshold); - tool->SetLevel(m_Level); - - tool->UpdatePreview(); - } - catch (const std::exception& e) - { - this->setCursor(Qt::ArrowCursor); - std::stringstream stream; - stream << "Error while generation watershed segmentation. Reason: " << e.what(); - - QMessageBox* messageBox = - new QMessageBox(QMessageBox::Critical, - nullptr, stream.str().c_str()); - messageBox->exec(); - delete messageBox; - MITK_ERROR << stream.str(); - return; - } - catch (...) - { - this->setCursor(Qt::ArrowCursor); - std::stringstream stream; - stream << "Unkown error occured while generation watershed segmentation."; - - QMessageBox* messageBox = - new QMessageBox(QMessageBox::Critical, - nullptr, stream.str().c_str()); - messageBox->exec(); - delete messageBox; - MITK_ERROR << stream.str(); - return; - } - - this->SetLabelSetPreview(tool->GetMLPreview()); - tool->IsTimePointChangeAwareOn(); - } -} - -void QmitkWatershedToolGUI::EnableWidgets(bool enabled) -{ - Superclass::EnableWidgets(enabled); - m_Controls.levelSlider->setEnabled(enabled); - m_Controls.thresholdSlider->setEnabled(enabled); - m_Controls.previewButton->setEnabled(enabled); -} - - -void QmitkWatershedToolGUI::OnLevelChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetLevel(value); - } -} - -void QmitkWatershedToolGUI::OnThresholdChanged(double value) -{ - auto tool = this->GetConnectedToolAs(); - if (nullptr != tool) - { - tool->SetThreshold(value); - } -} diff --git a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h deleted file mode 100644 index 193257e01f..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h +++ /dev/null @@ -1,66 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QmitkWatershedToolGUI_h_Included -#define QmitkWatershedToolGUI_h_Included - -#include "QmitkAutoMLSegmentationToolGUIBase.h" - -#include "ui_QmitkWatershedToolGUIControls.h" - -#include - -/** - \ingroup org_mitk_gui_qt_interactivesegmentation_internal - \brief GUI for mitk::WatershedTool. - \sa mitk::WatershedTool - - This GUI shows two sliders to change the watershed parameters. It executes the watershed algorithm by clicking on the - button. - -*/ -class MITKSEGMENTATIONUI_EXPORT QmitkWatershedToolGUI : public QmitkAutoMLSegmentationToolGUIBase -{ - Q_OBJECT - -public: - mitkClassMacro(QmitkWatershedToolGUI, QmitkAutoMLSegmentationToolGUIBase); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - -protected slots : - - void OnSettingsAccept(); - - void OnLevelChanged(double value); - void OnThresholdChanged(double value); - -protected: - QmitkWatershedToolGUI(); - ~QmitkWatershedToolGUI() = default; - - void ConnectNewTool(mitk::AutoSegmentationWithPreviewTool* newTool) override; - void InitializeUI(QBoxLayout* mainLayout) override; - - void EnableWidgets(bool enabled) override; - - //Recommendation from ITK is to have a threshold:level ration around 1:100 - //we set Level a bit higher. This provokes more oversegmentation, - //but produces less objects in the first run and profits form the fact that - //decreasing level is quite fast in the filter. - double m_Level = 0.6; - double m_Threshold = 0.004; - - Ui_QmitkWatershedToolGUIControls m_Controls; -}; - -#endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUIControls.ui b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUIControls.ui deleted file mode 100644 index 4ce970d215..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUIControls.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - QmitkWatershedToolGUIControls - - - - 0 - 0 - 192 - 352 - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100000 - 100000 - - - - QmitkOtsuToolWidget - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Level: - - - - - - - - 0 - 0 - - - - Threshold: - - - - - - - - - - - - - - - - 0 - 0 - - - - - 100000 - 16777215 - - - - Preview - - - - - - - - - ctkSliderWidget - QWidget -
ctkSliderWidget.h
- 1 -
-
- - -
diff --git a/Modules/SegmentationUI/files.cmake b/Modules/SegmentationUI/files.cmake index b3693314f8..17e542219b 100644 --- a/Modules/SegmentationUI/files.cmake +++ b/Modules/SegmentationUI/files.cmake @@ -1,94 +1,85 @@ set( CPP_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUI.cpp Qmitk/QmitkAutoSegmentationToolGUIBase.cpp Qmitk/QmitkAutoMLSegmentationToolGUIBase.cpp Qmitk/QmitkBinaryThresholdToolGUIBase.cpp Qmitk/QmitkBinaryThresholdToolGUI.cpp Qmitk/QmitkBinaryThresholdULToolGUI.cpp Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp Qmitk/QmitkConfirmSegmentationDialog.cpp Qmitk/QmitkCopyToClipBoardDialog.cpp Qmitk/QmitkDrawPaintbrushToolGUI.cpp Qmitk/QmitkErasePaintbrushToolGUI.cpp -Qmitk/QmitkFastMarchingToolGUIBase.cpp -Qmitk/QmitkFastMarchingTool3DGUI.cpp -Qmitk/QmitkFastMarchingToolGUI.cpp Qmitk/QmitkLiveWireTool2DGUI.cpp Qmitk/QmitkNewSegmentationDialog.cpp Qmitk/QmitkOtsuTool3DGUI.cpp Qmitk/QmitkPaintbrushToolGUI.cpp Qmitk/QmitkPickingToolGUI.cpp Qmitk/QmitkPixelManipulationToolGUI.cpp Qmitk/QmitkSlicesInterpolator.cpp Qmitk/QmitkToolGUI.cpp Qmitk/QmitkToolGUIArea.cpp Qmitk/QmitkToolSelectionBox.cpp -Qmitk/QmitkWatershedToolGUI.cpp Qmitk/QmitknnUNetToolGUI.cpp Qmitk/QmitknnUNetToolSlots.cpp #Added from ML Qmitk/QmitkLabelSetWidget.cpp Qmitk/QmitkSurfaceStampWidget.cpp Qmitk/QmitkMaskStampWidget.cpp Qmitk/QmitkSliceBasedInterpolatorWidget.cpp Qmitk/QmitkSurfaceBasedInterpolatorWidget.cpp Qmitk/QmitkSimpleLabelSetListWidget.cpp ) set(MOC_H_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h Qmitk/QmitkAutoSegmentationToolGUIBase.h Qmitk/QmitkAutoMLSegmentationToolGUIBase.h Qmitk/QmitkBinaryThresholdToolGUIBase.h Qmitk/QmitkBinaryThresholdToolGUI.h Qmitk/QmitkBinaryThresholdULToolGUI.h Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h Qmitk/QmitkConfirmSegmentationDialog.h Qmitk/QmitkCopyToClipBoardDialog.h Qmitk/QmitkDrawPaintbrushToolGUI.h Qmitk/QmitkErasePaintbrushToolGUI.h -Qmitk/QmitkFastMarchingToolGUIBase.h -Qmitk/QmitkFastMarchingTool3DGUI.h -Qmitk/QmitkFastMarchingToolGUI.h Qmitk/QmitkLiveWireTool2DGUI.h Qmitk/QmitkNewSegmentationDialog.h Qmitk/QmitkOtsuTool3DGUI.h Qmitk/QmitkPaintbrushToolGUI.h Qmitk/QmitkPickingToolGUI.h Qmitk/QmitkPixelManipulationToolGUI.h Qmitk/QmitkSlicesInterpolator.h Qmitk/QmitkToolGUI.h Qmitk/QmitkToolGUIArea.h Qmitk/QmitkToolSelectionBox.h -Qmitk/QmitkWatershedToolGUI.h Qmitk/QmitknnUNetToolGUI.h Qmitk/QmitknnUNetGPU.h Qmitk/QmitknnUNetEnsembleLayout.h Qmitk/QmitknnUNetFolderParser.h #Added from ML Qmitk/QmitkLabelSetWidget.h Qmitk/QmitkSurfaceStampWidget.h Qmitk/QmitkMaskStampWidget.h Qmitk/QmitkSliceBasedInterpolatorWidget.h Qmitk/QmitkSurfaceBasedInterpolatorWidget.h Qmitk/QmitkSimpleLabelSetListWidget.h ) set(UI_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUIControls.ui Qmitk/QmitkConfirmSegmentationDialog.ui Qmitk/QmitkOtsuToolWidgetControls.ui Qmitk/QmitkLiveWireTool2DGUIControls.ui -Qmitk/QmitkWatershedToolGUIControls.ui #Added from ML Qmitk/QmitkLabelSetWidgetControls.ui Qmitk/QmitkSurfaceStampWidgetGUIControls.ui Qmitk/QmitkMaskStampWidgetGUIControls.ui Qmitk/QmitkSliceBasedInterpolatorWidgetGUIControls.ui Qmitk/QmitkSurfaceBasedInterpolatorWidgetGUIControls.ui Qmitk/QmitknnUNetToolGUIControls.ui ) set(QRC_FILES resources/SegmentationUI.qrc ) diff --git a/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_3DWatershedTool.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_3DWatershedTool.png deleted file mode 100644 index a82c1aa1b3..0000000000 Binary files a/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_3DWatershedTool.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_IMG2DFastMarchingUsage.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_IMG2DFastMarchingUsage.png deleted file mode 100644 index 9f1ac4f3b3..0000000000 Binary files a/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentation_IMG2DFastMarchingUsage.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.segmentation/plugin.xml b/Plugins/org.mitk.gui.qt.segmentation/plugin.xml index b0753685a8..7da109cf6a 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/plugin.xml +++ b/Plugins/org.mitk.gui.qt.segmentation/plugin.xml @@ -1,82 +1,80 @@ Allows the segmentation of images using different tools. Edit segmentations using standard operations. - -