32 #include <itkBinaryThresholdImageFilter.h>
33 #include <itkOrImageFilter.h>
34 #include <itkOtsuMultipleThresholdsImageFilter.h>
59 Superclass::Activated();
63 m_OriginalImage =
dynamic_cast<mitk::Image *
>(m_ToolManager->GetReferenceData(0)->GetData());
66 m_BinaryPreviewNode->SetName(
"Binary_Preview");
71 m_ToolManager->GetDataStorage()->Add(this->m_BinaryPreviewNode);
74 m_MultiLabelResultNode->SetName(
"Otsu_Preview");
76 m_MultiLabelResultNode->SetVisibility(
true);
79 m_MaskedImagePreviewNode->SetName(
"Volume_Preview");
81 m_MaskedImagePreviewNode->SetVisibility(
false);
83 m_ToolManager->GetDataStorage()->Add(this->m_MultiLabelResultNode);
89 m_ToolManager->GetDataStorage()->Remove(this->m_MultiLabelResultNode);
90 m_MultiLabelResultNode = NULL;
91 m_ToolManager->GetDataStorage()->Remove(this->m_BinaryPreviewNode);
92 m_BinaryPreviewNode = NULL;
93 m_ToolManager->GetDataStorage()->Remove(this->m_MaskedImagePreviewNode);
94 m_MaskedImagePreviewNode = NULL;
96 Superclass::Deactivated();
115 int numberOfThresholds = regions - 1;
122 otsuFilter->SetNumberOfThresholds(numberOfThresholds);
123 otsuFilter->SetValleyEmphasis(useValley);
124 otsuFilter->SetNumberOfBins(numberOfBins);
125 otsuFilter->SetInput(image3D);
129 otsuFilter->Update();
133 mitkThrow() <<
"itkOtsuFilter error (image dimension must be in {2, 3} and image must not be RGB)";
136 m_ToolManager->GetDataStorage()->Remove(this->m_MultiLabelResultNode);
137 m_MultiLabelResultNode = NULL;
139 m_MultiLabelResultNode->SetName(
"Otsu_Preview");
140 m_MultiLabelResultNode->SetVisibility(
true);
141 m_ToolManager->GetDataStorage()->Add(this->m_MultiLabelResultNode);
142 m_MultiLabelResultNode->SetOpacity(1.0);
145 resultImage->InitializeByLabeledImage(otsuFilter->GetOutput());
146 this->m_MultiLabelResultNode->SetData(resultImage);
150 m_MultiLabelResultNode->SetProperty(
"Image Rendering.Mode", renderingMode);
154 lookupTable->SetHueRange(1.0, 0.0);
155 lookupTable->SetSaturationRange(1.0, 1.0);
156 lookupTable->SetValueRange(1.0, 1.0);
157 lookupTable->SetTableRange(-1.0, 1.0);
158 lookupTable->Build();
159 lut->SetVtkLookupTable(lookupTable);
160 prop->SetLookupTable(lut);
161 m_MultiLabelResultNode->SetProperty(
"LookupTable", prop);
165 levWinProp->SetLevelWindow(levelwindow);
166 m_MultiLabelResultNode->SetProperty(
"levelwindow", levWinProp);
177 resultImage->InitializeByLabeledImage(dynamic_cast<mitk::Image *>(m_BinaryPreviewNode->GetData()));
178 GetTargetSegmentationNode()->SetData(resultImage);
180 m_ToolManager->ActivateTool(-1);
185 m_MultiLabelResultNode->SetVisibility(
false);
187 AccessByItk_1(multiLabelSegmentation, CalculatePreview, regionIDs);
190 template <
typename TPixel,
unsigned int VImageDimension>
194 typedef itk::Image<mitk::Tool::DefaultSegmentationDataType, VImageDimension> OutputImageType;
196 typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> FilterType;
208 filter->SetInput(itkImage);
209 filter->SetLowerThreshold(regionIDs[0]);
210 filter->SetUpperThreshold(regionIDs[0]);
211 filter->SetInsideValue(1);
212 filter->SetOutsideValue(0);
214 itkBinaryTempImage2 = filter->GetOutput();
220 for (std::vector<int>::iterator it = regionIDs.begin(); it != regionIDs.end(); ++it)
222 filter->SetLowerThreshold(*it);
223 filter->SetUpperThreshold(*it);
224 filter->SetInsideValue(1);
225 filter->SetOutsideValue(0);
227 itkBinaryTempImage1 = filter->GetOutput();
229 orFilter->SetInput1(itkBinaryTempImage1);
230 orFilter->SetInput2(itkBinaryTempImage2);
232 orFilter->UpdateLargestPossibleRegion();
233 itkBinaryResultImage = orFilter->GetOutput();
234 itkBinaryTempImage2 = itkBinaryResultImage;
239 m_BinaryPreviewNode->SetData(binarySegmentation);
240 m_BinaryPreviewNode->SetVisibility(
true);
289 m_MaskedImagePreviewNode->SetBoolProperty(
"volumerendering",
true);
290 m_MaskedImagePreviewNode->SetBoolProperty(
"volumerendering.uselod",
true);
294 m_MaskedImagePreviewNode->SetBoolProperty(
"volumerendering",
false);
301 m_MultiLabelResultNode->SetVisibility(show);
302 m_BinaryPreviewNode->SetVisibility(!show);
308 ScalarType min = m_OriginalImage.GetPointer()->GetStatistics()->GetScalarValueMin();
309 ScalarType max = m_OriginalImage.GetPointer()->GetStatistics()->GetScalarValueMaxNoRecompute();
310 return static_cast<int>(max -
min) + 1;
const SliceNavigationController * GetTimeNavigationController() const
itk::SmartPointer< Self > Pointer
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
void SetRangeMinMax(ScalarType min, ScalarType max)
The LevelWindow class Class to store level/window values.
itk::Image< double, 3 > InputImageType
static RenderingManager * GetInstance()
Module * GetModule() const
Image class for storing images.
virtual unsigned int GetPos() const
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
mitk::Stepper * GetTime()
Get the Stepper through the time.
ModuleResource GetResource(const std::string &path) const
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.