diff --git a/Modules/MitkExt/Algorithms/itkConnectedAdaptiveThresholdImageFilter.h b/Modules/MitkExt/Algorithms/itkConnectedAdaptiveThresholdImageFilter.h index 905d36a6c1..90280a79fc 100644 --- a/Modules/MitkExt/Algorithms/itkConnectedAdaptiveThresholdImageFilter.h +++ b/Modules/MitkExt/Algorithms/itkConnectedAdaptiveThresholdImageFilter.h @@ -1,120 +1,119 @@ #ifndef __itkConnectedAdaptiveThresholdImageFilter_h #define __itkConnectedAdaptiveThresholdImageFilter_h #include "itkImage.h" -#include "MitkSBExports.h" #include "itkConnectedThresholdImageFilter.h" namespace itk { /** /class ConnectedAdaptiveThreholdImageFilter * \brief ImageFilter used for processing an image with an adaptive * iterator (such as itkAdaptiveThresholdIterator) * * \ingroup RegionGrowingSegmentation */ template class ITK_EXPORT ConnectedAdaptiveThresholdImageFilter: public ConnectedThresholdImageFilter { public: /** Standard class typedefs. */ typedef ConnectedAdaptiveThresholdImageFilter Self; typedef ConnectedThresholdImageFilter Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ConnectedAdaptiveThresholdImageFilter, ConnectedThresholdImageFilter); typedef TInputImage InputImageType; typedef TOutputImage OutputImageType; typedef typename OutputImageType::Pointer OutputImagePointer; typedef typename InputImageType::IndexType IndexType; void SetGrowingDirectionIsUpwards(bool upwards) { m_GrowingDirectionIsUpwards = upwards; } /* Switch between fine and raw leakage detection. */ void SetFineDetectionMode(bool fine) {m_FineDetectionMode = fine; m_DiscardLastPreview = false;} int GetSeedpointValue(void) {return m_SeedpointValue;} int GetLeakagePoint(void) {return m_DetectedLeakagePoint;} bool m_SegmentationCancelled; /* * Correct the position of the seed point, only performed if seed point value is outside threshold range * @param sizeOfVolume edge length of the square volume in which the search for a "better" seed is performed */ IndexType CorrectSeedPointPosition(unsigned int sizeOfVolume, int lowerTh, int upperTh); /* Sets all voxels in a square volume with the size of @param croppingSize * and the center point equal to @param seedPoint to the value zero. */ void CropMask(unsigned int croppingSize); /* Modifies the iterator mask to keep all previous segmentation results in the same mask. * @returnParam largest value in the segmentation mask */ unsigned int AdjustIteratorMask(); /* Sets parameters needed for adjusting the iterator mask * @param iteratorMaskForFineSegmentation pointer to the image containing the complete segmentation result of one leaf (inclusively leakage-segmentation) * @param adjLowerTh lower threshold value of the segmentation without leakage-segmentation * @param adjLowerTh upper threshold value of the segmentation without leakage-segmentation * @param discardLeafSegmentation flag if the last segmentation preview ended with a leakage already in the first step */ void SetParameterForFineSegmentation( TOutputImage * iteratorMaskForFineSegmentation ,unsigned int adjLowerTh, unsigned int adjUpperTh, itk::Index<3> seedPoint, bool discardLeafSegmentation); TOutputImage* GetResultImage(); protected: ConnectedAdaptiveThresholdImageFilter(); ~ConnectedAdaptiveThresholdImageFilter(){}; void GenerateData(); TOutputImage * m_IteratorMaskForFineSegmentation; private: OutputImagePointer m_OutoutImageMaskFineSegmentation; bool m_GrowingDirectionIsUpwards; int m_SeedpointValue; int m_DetectedLeakagePoint; int m_InitValue ; unsigned int m_AdjLowerTh; unsigned int m_AdjUpperTh; itk::Index<3> m_SeedPointIndex; /* Flag for switching between raw segmentation and fine segmentation (Bronchial tree segmentation) */ bool m_FineDetectionMode; bool m_DiscardLastPreview; }; }// end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkConnectedAdaptiveThresholdImageFilter.txx" #endif #endif diff --git a/Modules/MitkExt/Interactions/mitkPixelManipulationTool.cpp b/Modules/MitkExt/Interactions/mitkPixelManipulationTool.cpp index 7420e812fa..2598485567 100644 --- a/Modules/MitkExt/Interactions/mitkPixelManipulationTool.cpp +++ b/Modules/MitkExt/Interactions/mitkPixelManipulationTool.cpp @@ -1,169 +1,171 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPixelManipulationTool.h" #include "mitkToolManager.h" #include "mitkImageCast.h" #include "mitkProperties.h" #include "mitkBoundingObjectToSegmentationFilter.h" #include +#include "mitkPixelManipulationTool.xpm" + namespace mitk { MITK_TOOL_MACRO(MitkExt_EXPORT, PixelManipulationTool, "Pixel manipulation tool"); } mitk::PixelManipulationTool::PixelManipulationTool() : Tool("dummy"), m_Value(0), m_FixedValue(false) { this->SupportRoiOn(); } mitk::PixelManipulationTool::~PixelManipulationTool() { } void mitk::PixelManipulationTool::Activated() { m_ToolManager->RoiDataChanged += mitk::MessageDelegate (this,&mitk::PixelManipulationTool::OnRoiDataChanged); m_OriginalImageNode = m_ToolManager->GetReferenceData(0); if (m_OriginalImageNode.IsNotNull()) { mitk::Image::Pointer image = dynamic_cast (m_OriginalImageNode->GetData()); if ( image.IsNotNull()) { - mitk::ScalarType scalar = image->GetScalarValueMax(); + //mitk::ScalarType scalar = image->GetScalarValueMax(); } } else m_ToolManager->ActivateTool(-1); } void mitk::PixelManipulationTool::Deactivated() { m_ToolManager->RoiDataChanged -= mitk::MessageDelegate (this,&mitk::PixelManipulationTool::OnRoiDataChanged); } const char* mitk::PixelManipulationTool::GetName() const { return "pixelmanipulation"; } const char** mitk::PixelManipulationTool::GetXPM() const { return mitkPixelManipulationTool_xpm; } void mitk::PixelManipulationTool::OnRoiDataChanged() { } void mitk::PixelManipulationTool::CalculateImage() { if (m_OriginalImageNode.IsNotNull()) { mitk::Image::Pointer image = dynamic_cast (m_OriginalImageNode->GetData()); mitk::DataNode* maskNode = m_ToolManager->GetRoiData(0); mitk::Image::Pointer roi = mitk::Image::New(); if (maskNode) { mitk::BoundingObject* boundingObject = dynamic_cast (maskNode->GetData()); if (boundingObject) { mitk::BoundingObjectToSegmentationFilter::Pointer filter = mitk::BoundingObjectToSegmentationFilter::New(); filter->SetBoundingObject( boundingObject); filter->SetInput(image); filter->Update(); roi = filter->GetOutput(); } else roi = dynamic_cast (maskNode->GetData()); mitk::Image::Pointer newImage = mitk::Image::New(); newImage->Initialize(image); if (image) { AccessByItk_3(image, ITKPixelManipulation, roi, newImage, m_Value); this->AddImageToDataStorage(newImage); } } } } template void mitk::PixelManipulationTool::ITKPixelManipulation( itk::Image* originalImage, Image* maskImage, Image* newImage, int newValue) { typedef itk::Image< TPixel, VImageDimension> itkImageType; typedef itk::Image< unsigned char, 3> itkMaskType; typename itkImageType::Pointer itkImage; typename itkMaskType::Pointer itkMask; CastToItkImage( newImage, itkImage); CastToItkImage( maskImage, itkMask); typedef itk::ImageRegionConstIterator< itkImageType > InputIteratorType; typedef itk::ImageRegionIterator< itkImageType > OutputIteratorType; typedef itk::ImageRegionConstIterator< itkMaskType > MaskIteratorType; MaskIteratorType maskIterator ( itkMask, itkMask->GetLargestPossibleRegion() ); InputIteratorType inputIterator( originalImage, originalImage->GetLargestPossibleRegion() ); OutputIteratorType outputIterator( itkImage, itkImage->GetLargestPossibleRegion() ); inputIterator.GoToBegin(); outputIterator.GoToBegin(); maskIterator.GoToBegin(); while (!outputIterator.IsAtEnd()) { if (maskIterator.Get()) { if (m_FixedValue) outputIterator.Set(newValue); else outputIterator.Set( inputIterator.Get()+ newValue); } else outputIterator.Set( inputIterator.Get()); ++inputIterator; ++outputIterator; ++maskIterator; } } void mitk::PixelManipulationTool::AddImageToDataStorage(mitk::Image::Pointer image) { if (image.IsNotNull()) { mitk::DataNode::Pointer node = mitk::DataNode::New(); std::string name = m_OriginalImageNode->GetName(); name.append("_modified"); node->SetName(name); node->SetProperty("binary", mitk::BoolProperty::New(false)); node->SetData(image); if (m_ToolManager) m_ToolManager->GetDataStorage()->Add(node, m_OriginalImageNode); } } \ No newline at end of file diff --git a/Modules/MitkExt/Interactions/mitkPixelManipulationTool.h b/Modules/MitkExt/Interactions/mitkPixelManipulationTool.h index 04be9276f8..8144b921b2 100644 --- a/Modules/MitkExt/Interactions/mitkPixelManipulationTool.h +++ b/Modules/MitkExt/Interactions/mitkPixelManipulationTool.h @@ -1,65 +1,64 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKPIXELMANIPULATIONTOOL_H #define MITKPIXELMANIPULATIONTOOL_H #include "mitkTool.h" -#include "mitkPixelManipulationTool.xpm" #include "MitkExtExports.h" #include "itkImage.h" namespace mitk { class MitkExt_EXPORT PixelManipulationTool : public Tool { public: mitkClassMacro(PixelManipulationTool, Tool); itkNewMacro(PixelManipulationTool); itkSetMacro(Value, int); itkGetMacro(Value, int); itkSetMacro(FixedValue, bool); itkGetMacro(FixedValue, bool); itkBooleanMacro(FixedValue); virtual const char* GetName() const; virtual const char** GetXPM() const; virtual void Activated(); virtual void Deactivated(); virtual void CalculateImage(); protected: PixelManipulationTool(); virtual ~PixelManipulationTool(); virtual void OnRoiDataChanged(); void AddImageToDataStorage(mitk::Image::Pointer image); template void ITKPixelManipulation( itk::Image* originalImage, Image* maskImage, Image* newImage, int newValue); mitk::DataNode::Pointer m_OriginalImageNode; int m_Value; bool m_FixedValue; };//clas }//namespace #endif diff --git a/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.cpp b/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.cpp index 616a08fa64..576f6b8683 100644 --- a/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.cpp +++ b/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.cpp @@ -1,439 +1,441 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkRegionGrow3DTool.h" #include "mitkToolManager.h" #include "mitkRenderingManager.h" #include "mitkLevelWindowProperty.h" #include "mitkPointSetInteractor.h" #include "mitkGlobalInteraction.h" #include "mitkITKImageImport.h" #include "itkImage.h" #include "itkBinaryThresholdImageFilter.h" #include "itkConnectedAdaptiveThresholdImageFilter.h" #include "mitkImageCast.h" #include "mitkMaskAndCutRoiImageFilter.h" #include "mitkPadImageFilter.h" +#include "mitkRegionGrow3DTool.xpm" + namespace mitk { MITK_TOOL_MACRO(MitkExt_EXPORT, RegionGrow3DTool, "RegionGrower 3D"); } mitk::RegionGrow3DTool::RegionGrow3DTool(): Tool("PressMoveRelease"), m_LowerThreshold(-5000), m_UpperThreshold(5000), m_CurrentRGDirectionIsUpwards(false) { CONNECT_ACTION( 42, OnMouseReleased ); this->SupportRoiOn(); m_FeedbackNode = DataNode::New(); m_FeedbackNode->SetProperty( "color", ColorProperty::New(1.0, 0.0, 0.0) ); m_FeedbackNode->SetProperty( "texture interpolation", BoolProperty::New(false) ); m_FeedbackNode->SetProperty( "layer", IntProperty::New( 100 ) ); m_FeedbackNode->SetProperty( "levelwindow", LevelWindowProperty::New( LevelWindow(100, 1) ) ); m_FeedbackNode->SetProperty( "name", StringProperty::New("failsafe region grow feedback") ); m_FeedbackNode->SetProperty( "opacity", FloatProperty::New(0.3) ); m_FeedbackNode->SetProperty( "helper object", BoolProperty::New(true) ); m_FeedbackNode->SetVisibility(false); m_PointSetNode = mitk::DataNode::New(); m_PointSetNode->SetName("regiongrow3d pointset"); m_PointSetNode->SetProperty("helper object", mitk::BoolProperty::New(true)); m_PointSetNode->SetProperty("layer", mitk::IntProperty::New(2)); mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); m_PointSetNode->SetData(pointSet); } mitk::RegionGrow3DTool::~RegionGrow3DTool() { } bool mitk::RegionGrow3DTool::OnMouseReleased(Action*, const StateEvent* stateEvent) { mitk::PointSetInteractor::Pointer interactor = dynamic_cast (m_PointSetNode->GetInteractor()); if (interactor.IsNotNull()) { mitk::PointSet::Pointer pointSet = dynamic_cast (m_PointSetNode->GetData()); if (pointSet.IsNotNull()) { if (pointSet->GetSize() == 1) { //check if we have a valid picture this->RunSegmentation(); SeedButtonToggled.Send(false); } } } return true; } void mitk::RegionGrow3DTool::Activated() { if (m_ToolManager) { m_ToolManager->RoiDataChanged += mitk::MessageDelegate(this, &mitk::RegionGrow3DTool::UpdatePreview); m_OriginalImageNode = m_ToolManager->GetReferenceData(0); m_NodeToProceed = m_OriginalImageNode; if (m_NodeToProceed.IsNotNull()) { SetupPreviewNodeFor(m_NodeToProceed); mitk::Image::Pointer image = dynamic_cast (m_OriginalImageNode->GetData()); if (image.IsNotNull()) { m_RoiMin = image->GetScalarValueMin(); m_RoiMax = image->GetScalarValueMax(); } } else m_ToolManager->ActivateTool(-1); } } void mitk::RegionGrow3DTool::Deactivated() { m_ToolManager->RoiDataChanged -= mitk::MessageDelegate(this, &mitk::RegionGrow3DTool::UpdatePreview); if (mitk::DataStorage* ds = m_ToolManager->GetDataStorage()) { ds->Remove(m_PointSetNode); ds->Remove(m_FeedbackNode); } m_FeedbackNode->SetData(NULL); m_FeedbackNode->SetLevelWindow(NULL); m_FeedbackNode->SetVisibility(false); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } const char* mitk::RegionGrow3DTool::GetName() const { return "RegionGrower 3D"; } const char** mitk::RegionGrow3DTool::GetXPM() const { return mitkRegionGrow3DTool_xpm; } void mitk::RegionGrow3DTool::SetSeedPoint(bool toggled) { if (!m_ToolManager->GetDataStorage()->Exists(m_PointSetNode)) //no pointSet present m_ToolManager->GetDataStorage()->Add(m_PointSetNode, m_OriginalImageNode); //add Interactor if there is none and add it to GlobalInteraction if (toggled == true) // button is down { mitk::PointSetInteractor::Pointer interactor = dynamic_cast (m_PointSetNode->GetInteractor()); if (interactor.IsNull()) { //create a new interactor and add it to node interactor = mitk::PointSetInteractor::New("singlepointinteractorwithoutshiftclick", m_PointSetNode, 1); } mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor); } else { mitk::PointSetInteractor::Pointer interactor = dynamic_cast (m_PointSetNode->GetInteractor()); if (interactor.IsNotNull()) { m_PointSetNode->SetInteractor(NULL); mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor); } } } void mitk::RegionGrow3DTool::RunSegmentation() { //safety if no pointSet or pointSet empty mitk::PointSet::Pointer seedPointSet = dynamic_cast (m_PointSetNode->GetData()); if (seedPointSet.IsNull()) { return; } if (!(seedPointSet->GetSize() > 0)) { return; } mitk::PointSet::PointType seedPoint = seedPointSet->GetPointSet()->GetPoints()->Begin().Value(); mitk::Image::Pointer image = dynamic_cast (m_NodeToProceed->GetData()); if (image.IsNotNull()) { m_LowerThreshold = static_cast (m_RoiMin); m_UpperThreshold = static_cast (m_RoiMax); AccessByItk_2(image, StartRegionGrowing, image->GetGeometry(), seedPoint); } } template void mitk::RegionGrow3DTool::StartRegionGrowing(itk::Image* itkImage, mitk::Geometry3D* imageGeometry, mitk::PointSet::PointType seedPoint) { typedef itk::Image InputImageType; typedef typename InputImageType::IndexType IndexType; typedef itk::ConnectedAdaptiveThresholdImageFilter RegionGrowingFilterType; typename RegionGrowingFilterType::Pointer regionGrower = RegionGrowingFilterType::New(); if ( !imageGeometry->IsInside(seedPoint) ) { return; } IndexType seedIndex; imageGeometry->WorldToIndex( seedPoint, seedIndex);// convert world coordinates to image indices - int seedValue = itkImage->GetPixel(seedIndex); + //int seedValue = itkImage->GetPixel(seedIndex); regionGrower->SetInput( itkImage ); regionGrower->AddSeed( seedIndex ); regionGrower->SetLower( m_LowerThreshold ); regionGrower->SetUpper( m_UpperThreshold ); regionGrower->SetGrowingDirectionIsUpwards( m_CurrentRGDirectionIsUpwards ); try { regionGrower->Update(); } catch( ... ) { MITK_ERROR << "Something went wrong!" << endl; return; } m_SeedpointValue = regionGrower->GetSeedpointValue(); //initialize slider if(m_CurrentRGDirectionIsUpwards) { UpperThresholdValueChanged.Send(m_UpperThreshold); LowerThresholdValueChanged.Send(m_SeedpointValue); } else { UpperThresholdValueChanged.Send(m_SeedpointValue); LowerThresholdValueChanged.Send(m_LowerThreshold); } m_DetectedLeakagePoint = regionGrower->GetLeakagePoint(); mitk::Image::Pointer resultImage = mitk::ImportItkImage( regionGrower->GetOutput() ); m_FeedbackNode->SetData( resultImage ); m_FeedbackNode->SetVisibility(true); InitializeLevelWindow(); } void mitk::RegionGrow3DTool::InitializeLevelWindow() { mitk::LevelWindow tempLevelWindow; m_FeedbackNode->GetLevelWindow(tempLevelWindow, NULL, "levelWindow"); mitk::ScalarType* level = new mitk::ScalarType(0.5); mitk::ScalarType* window = new mitk::ScalarType(1); int upper; if (m_CurrentRGDirectionIsUpwards) { upper = m_UpperThreshold - m_SeedpointValue; } else { upper = m_SeedpointValue - m_LowerThreshold; } tempLevelWindow.SetRangeMinMax(mitk::ScalarType(0), mitk::ScalarType(upper)); tempLevelWindow.SetLevelWindow(*level, *window); m_FeedbackNode->SetLevelWindow(tempLevelWindow, NULL, "levelWindow"); //get the suggested threshold from the detected leakage-point and adjust the slider if (m_CurrentRGDirectionIsUpwards) { SliderValueChanged.Send(m_SeedpointValue + m_DetectedLeakagePoint -1); } else { SliderValueChanged.Send(m_SeedpointValue - m_DetectedLeakagePoint +1); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::RegionGrow3DTool::ChangeLevelWindow(int value) { if (m_FeedbackNode.IsNull()) return; mitk::LevelWindow tempLevelWindow; m_FeedbackNode->GetLevelWindow(tempLevelWindow, NULL, "levelWindow"); //get the levelWindow associated with the preview mitk::ScalarType level;// = this->m_UPPERTHRESHOLD - newValue + 0.5; mitk::ScalarType* window = new mitk::ScalarType(1); //adjust the levelwindow according to the position of the slider (newvalue) if (m_CurrentRGDirectionIsUpwards) { level = m_UpperThreshold - value + 0.5; tempLevelWindow.SetLevelWindow(level, *window); } else { level = value - m_LowerThreshold +0.5; tempLevelWindow.SetLevelWindow(level, *window); } m_FeedbackNode->SetLevelWindow(tempLevelWindow, NULL, "levelWindow"); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::RegionGrow3DTool::ConfirmSegmentation( std::string name, mitk::Color color) { mitk::DataNode::Pointer new_node = mitk::DataNode::New(); new_node->SetColor(color); new_node->SetName(name); new_node->SetProperty("binary", mitk::BoolProperty::New("true")); mitk::Image* image = dynamic_cast (m_FeedbackNode->GetData()); mitk::LevelWindow tempLevelWindow; m_FeedbackNode->GetLevelWindow( tempLevelWindow, NULL, "levelWindow"); int upperThresholdLabeledImage = (short int) tempLevelWindow.GetRangeMax(); int lowerThresholdLabeledImage = (short int) tempLevelWindow.GetLowerWindowBound() + 1; typedef itk::Image InputImageType; typedef itk::Image SegmentationType; typedef itk::BinaryThresholdImageFilter ThresholdFilterType; ThresholdFilterType::Pointer filter = ThresholdFilterType::New(); InputImageType::Pointer itkImage; mitk::CastToItkImage(image, itkImage); filter->SetInput(itkImage); filter->SetInsideValue(1); filter->SetOutsideValue(0); filter->SetUpperThreshold(upperThresholdLabeledImage); filter->SetLowerThreshold(lowerThresholdLabeledImage); filter->Update(); mitk::Image::Pointer new_image = mitk::Image::New(); mitk::CastToMitkImage(filter->GetOutput(), new_image); //pad to original size if (m_OriginalImageNode.GetPointer() != m_NodeToProceed.GetPointer()) { mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New(); padFilter->SetInput(0, new_image); padFilter->SetInput(1, dynamic_cast (m_OriginalImageNode->GetData())); padFilter->SetBinaryFilter(true); padFilter->SetUpperThreshold(1); padFilter->SetLowerThreshold(1); padFilter->Update(); new_image = padFilter->GetOutput(); } new_node->SetData(new_image); m_ToolManager->GetDataStorage()->Add(new_node); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); m_ToolManager->ActivateTool(-1); } void mitk::RegionGrow3DTool::CancelSegmentation() { m_ToolManager->ActivateTool(-1); } void mitk::RegionGrow3DTool::SetupPreviewNodeFor( DataNode* nodeToProceed) { if (nodeToProceed) { Image::Pointer image = dynamic_cast( nodeToProceed->GetData() ); if (image.IsNotNull()) { m_FeedbackNode->SetData( image ); int layer(50); nodeToProceed->GetIntProperty("layer", layer); m_FeedbackNode->SetIntProperty("layer", layer+1); m_FeedbackNode->SetLevelWindow(NULL); if (DataStorage* storage = m_ToolManager->GetDataStorage()) { if (storage->Exists(m_FeedbackNode)) storage->Remove(m_FeedbackNode); storage->Add( m_FeedbackNode, nodeToProceed ); } } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::RegionGrow3DTool::UpdatePreview() { typedef itk::Image ItkImageType; typedef itk::Image ItkMaskType; mitk::DataNode::Pointer node = m_ToolManager->GetRoiData(0); if (node.IsNull()) { this->SetupPreviewNodeFor(m_OriginalImageNode); m_NodeToProceed = m_OriginalImageNode; mitk::Image::Pointer image = dynamic_cast (m_OriginalImageNode->GetData()); if (image.IsNotNull()) { m_RoiMin = image->GetScalarValueMin(); m_RoiMax = image->GetScalarValueMax(); } return; } mitk::MaskAndCutRoiImageFilter::Pointer roiFilter = mitk::MaskAndCutRoiImageFilter::New(); roiFilter->SetInput(dynamic_cast (m_NodeToProceed->GetData())); roiFilter->SetRegionOfInterest(node->GetData()); roiFilter->Update(); mitk::DataNode::Pointer new_node = mitk::DataNode::New(); mitk::Image::Pointer tmpImage = roiFilter->GetOutput(); new_node->SetData(tmpImage); m_RoiMax = roiFilter->GetMaxValue(); m_RoiMin = roiFilter->GetMinValue(); this->SetupPreviewNodeFor(new_node); m_NodeToProceed = new_node; //this->RunSegmentation(); } void mitk::RegionGrow3DTool::SetCurrentRGDirectionIsUpwards(bool flag) { m_CurrentRGDirectionIsUpwards = flag; } diff --git a/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.h b/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.h index 1990814e67..85c9420576 100644 --- a/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.h +++ b/Modules/MitkExt/Interactions/mitkRegionGrow3DTool.h @@ -1,84 +1,83 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 28959 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKREGIONGROW3DTOOL_H #define MITKREGIONGROW3DTOOL_H #include "mitkTool.h" #include "mitkPointSet.h" -#include "mitkRegionGrow3DTool.xpm" #include "MitkExtExports.h" #include "mitkStateEvent.h" #include "itkImage.h" namespace mitk{ class MitkExt_EXPORT RegionGrow3DTool : public Tool { public: mitkClassMacro(RegionGrow3DTool, Tool); itkNewMacro(RegionGrow3DTool); mitk::Message1 UpperThresholdValueChanged; mitk::Message1 LowerThresholdValueChanged; mitk::Message1 SliderValueChanged; mitk::Message1 SeedButtonToggled; virtual const char* GetName() const; virtual const char** GetXPM() const; virtual void Activated(); virtual void Deactivated(); void RunSegmentation(); void ConfirmSegmentation(std::string name, mitk::Color color); void CancelSegmentation(); void InitializeLevelWindow(); void ChangeLevelWindow(int); void SetSeedPoint(bool); void SetCurrentRGDirectionIsUpwards(bool); protected: RegionGrow3DTool(); virtual ~RegionGrow3DTool(); void SetupPreviewNodeFor(mitk::DataNode* nodeToProceed); void UpdatePreview(); template < typename TPixel, unsigned int VImageDimension > void StartRegionGrowing( itk::Image< TPixel, VImageDimension >* itkImage, mitk::Geometry3D* imageGeometry, mitk::PointSet::PointType seedPoint ); bool OnMouseReleased(Action*, const StateEvent*); int m_SeedpointValue; mitk::ScalarType m_RoiMax; mitk::ScalarType m_RoiMin; int m_LowerThreshold; int m_UpperThreshold; int m_DetectedLeakagePoint; bool m_CurrentRGDirectionIsUpwards; mitk::DataNode::Pointer m_PointSetNode; mitk::DataNode::Pointer m_FeedbackNode; mitk::DataNode::Pointer m_NodeToProceed; mitk::DataNode::Pointer m_OriginalImageNode; };//class }//namespace #endif