25 #include <itkBinaryFillholeImageFilter.h> 26 #include <itkConnectedThresholdImageFilter.h> 46 Superclass::Activated();
51 Superclass::Deactivated();
65 if (workingSlice.IsNull())
69 const BaseGeometry *sliceGeometry = workingSlice->GetGeometry();
71 sliceGeometry->
WorldToIndex(positionEvent->GetPositionInWorld(), projectedPointIn2D);
74 MITK_WARN <<
"Point outside of segmentation slice." << std::endl;
79 typedef InputImageType::IndexType IndexType;
80 typedef itk::ConnectedThresholdImageFilter<InputImageType, InputImageType> RegionGrowingFilterType;
81 RegionGrowingFilterType::Pointer regionGrower = RegionGrowingFilterType::New();
85 sliceGeometry->
WorldToIndex(positionEvent->GetPositionInWorld(), seedIndex);
88 InputImageType::Pointer itkImage = InputImageType::New();
90 regionGrower->SetInput(itkImage);
91 regionGrower->AddSeed(seedIndex);
93 InputImageType::PixelType bound = itkImage->GetPixel(seedIndex);
95 regionGrower->SetLower(bound);
96 regionGrower->SetUpper(bound);
97 regionGrower->SetReplaceValue(1);
99 itk::BinaryFillholeImageFilter<InputImageType>::Pointer fillHolesFilter =
100 itk::BinaryFillholeImageFilter<InputImageType>::New();
102 fillHolesFilter->SetInput(regionGrower->GetOutput());
103 fillHolesFilter->SetForegroundValue(1);
107 resultImage->SetGeometry(workingSlice->GetGeometry());
114 contourextractor->SetInput(resultImage);
115 contourextractor->Update();
118 auto t = positionEvent->GetSender()->GetTimeStep();
134 assert(positionEvent->GetSender()->GetRenderWindow());
140 int timeStep = positionEvent->GetSender()->GetTimeStep();
146 auto *
image =
dynamic_cast<Image *
>(workingNode->GetData());
147 const PlaneGeometry *planeGeometry((positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()));
148 if (!
image || !planeGeometry)
155 MITK_ERROR <<
"Unable to extract slice." << std::endl;
161 slice, feedbackContour,
false,
false);
163 if (projectedContour.IsNull())
168 if (labelImage !=
nullptr)
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Super class for all position events.
virtual unsigned int GetSlice() const
static void FillContourInSlice(ContourModel *projectedContour, Image *sliceImage, mitk::Image::Pointer workingImage, int paintingPixelValue=1)
Fill a contour in a 2D slice with a specified pixel value at time step 0.
bool IsIndexInside(const mitk::Point3D &index) const
Test whether the point p ((continous!)index coordinates in units) is inside the bounding box...
::mitk::Image InputImageType
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
static RenderingManager * GetInstance()
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
Image class for storing images.
mitk::Label * GetActiveLabel(unsigned int layer=0)
Returns the active label of a specific layer.
mitk::Image::Pointer image
PixelType GetValue() const
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
void RequestUpdate(vtkRenderWindow *renderWindow)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
LabelSetImage class for handling labels and layers in a segmentation session.
Describes a two-dimensional, rectangular plane.
#define CONNECT_FUNCTION(a, f)
static ContourModel::Pointer MoveZerothContourTimeStep(const ContourModel *contour, unsigned int timeStep)
Move the contour in time step 0 to to a new contour model at the given time step. ...
BaseGeometry Describes the geometry of a data object.
Class for nodes of the DataTree.