32 #include <itkBinaryThresholdImageFilter.h> 33 #include <itkImageRegionIterator.h> 47 : m_SensibleMinimumThresholdValue(-100),
48 m_SensibleMaximumThresholdValue(+100),
49 m_CurrentLowerThresholdValue(1),
50 m_CurrentUpperThresholdValue(1)
78 return "UL Threshold";
83 Superclass::Activated();
121 Superclass::Deactivated();
149 itk::RGBPixel<float> pixel;
159 if (image.IsNotNull())
164 if (workingImage.IsNotNull())
173 if (previewImage.IsNull())
175 MITK_ERROR <<
"Cannot create helper objects.";
179 previewImage->GetActiveLabel()->SetColor(pixel);
180 previewImage->GetActiveLabelSet()->UpdateLookupTable(previewImage->GetActiveLabel()->GetValue());
207 if (image.GetPointer() == originalImage.GetPointer())
218 bool isFloatImage =
false;
219 if ((originalImage->GetPixelType().GetPixelType() == itk::ImageIOBase::SCALAR) &&
220 (originalImage->GetPixelType().GetComponentType() == itk::ImageIOBase::FLOAT ||
221 originalImage->GetPixelType().GetComponentType() == itk::ImageIOBase::DOUBLE))
232 template <
typename TPixel,
unsigned int VImageDimension>
233 static void ITKSetVolume(itk::Image<TPixel, VImageDimension> *originalImage,
235 unsigned int timeStep)
237 segmentation->
SetVolume((
void *)originalImage->GetPixelContainer()->GetBufferPointer(), timeStep);
245 if (feedBackImage.IsNotNull())
250 if (emptySegmentation)
253 for (
unsigned int timeStep = 0; timeStep < feedBackImage->GetTimeSteps(); ++timeStep)
258 timeSelector->SetInput(feedBackImage);
259 timeSelector->SetTimeNr(timeStep);
260 timeSelector->UpdateLargestPossibleRegion();
263 if (feedBackImage3D->GetDimension() == 2)
266 feedBackImage3D,
ITKSetVolume, 2, dynamic_cast<Image *>(emptySegmentation->GetData()), timeStep);
271 feedBackImage3D,
ITKSetVolume, 3, dynamic_cast<Image *>(emptySegmentation->GetData()), timeStep);
276 Tool::ErrorMessage(
"Error accessing single time steps of the original image. Cannot create segmentation.");
285 padFilter->SetInput(0, dynamic_cast<mitk::Image *>(emptySegmentation->GetData()));
287 padFilter->SetBinaryFilter(
true);
288 padFilter->SetUpperThreshold(1);
289 padFilter->SetLowerThreshold(1);
292 emptySegmentation->SetData(padFilter->GetOutput());
306 if (node.IsNotNull())
314 roiFilter->SetInput(image);
315 roiFilter->SetRegionOfInterest(node->GetData());
319 tmpNode->SetData(roiFilter->GetOutput());
333 template <
typename TPixel,
unsigned int VImageDimension>
338 unsigned int timeStep)
340 typedef itk::Image<TPixel, VImageDimension>
ImageType;
341 typedef itk::Image<mitk::Tool::DefaultSegmentationDataType, VImageDimension>
SegmentationType;
344 typename ThresholdFilterType::Pointer filter = ThresholdFilterType::New();
345 filter->SetInput(originalImage);
346 filter->SetLowerThreshold(lower);
347 filter->SetUpperThreshold(upper);
348 filter->SetInsideValue(1);
349 filter->SetOutsideValue(0);
352 segmentation->
SetVolume((
void *)(filter->GetOutput()->GetPixelContainer()->GetBufferPointer()), timeStep);
355 template <
typename TPixel,
unsigned int VImageDimension>
360 unsigned int timeStep)
362 typedef itk::Image<TPixel, VImageDimension>
ImageType;
366 typename ThresholdFilterType::Pointer filter = ThresholdFilterType::New();
367 filter->SetInput(originalImage);
368 filter->SetLowerThreshold(lower);
369 filter->SetUpperThreshold(upper);
370 filter->SetInsideValue(1);
371 filter->SetOutsideValue(0);
374 segmentation->
SetVolume((
void *)(filter->GetOutput()->GetPixelContainer()->GetBufferPointer()), timeStep);
381 if (thresholdImage && previewImage)
383 for (
unsigned int timeStep = 0; timeStep < thresholdImage->GetTimeSteps(); ++timeStep)
386 timeSelector->SetInput(thresholdImage);
387 timeSelector->SetTimeNr(timeStep);
388 timeSelector->UpdateLargestPossibleRegion();
Data management class that handles 'was created by' relations.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
#define AccessByItk_n(mitkImage, itkImageTypeFunction, va_tuple)
Access a MITK image by an ITK image with one or more parameters.
virtual bool SetVolume(const void *data, int t=0, int n=0)
Set data as volume at time t in channel n. It is in the responsibility of the caller to ensure that t...
virtual ScalarType GetScalarValueMin(int t=0, unsigned int component=0)
Get the minimum for scalar images. Recomputation performed only when necessary.
MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, LiveWireTool2D, "LiveWire tool")
#define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, arg1, arg2)
static RenderingManager * GetInstance()
virtual ScalarType GetScalarValueMax(int t=0, unsigned int component=0)
Get the maximum for scalar images. Recomputation performed only when necessary.
Module * GetModule() const
Image class for storing images.
ModuleResource GetResource(const std::string &path) const
mitk::Image::Pointer image
Class holding the statistics informations about a single mitk::Image.
LabelSetImage class for handling labels and layers in a segmentation session.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.