Medical Imaging Interaction Toolkit  2018.4.99-b585543d
Medical Imaging Interaction Toolkit
mitkSegTool2D.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkSegTool2D.h"
14 #include "mitkToolManager.h"
15 
16 #include "mitkBaseRenderer.h"
17 #include "mitkDataStorage.h"
18 
19 #include "mitkPlaneGeometry.h"
20 
22 #include "mitkExtractImageFilter.h"
23 
24 // Include of the new ImageExtractor
29 #include "mitkPlanarCircle.h"
30 
31 #include "usGetModuleContext.h"
32 
33 // Includes for 3DSurfaceInterpolation
34 #include "mitkImageTimeSelector.h"
37 
38 // includes for resling and overwriting
39 #include <mitkExtractSliceFilter.h>
40 #include <mitkVtkImageOverwrite.h>
41 #include <vtkImageData.h>
42 #include <vtkSmartPointer.h>
43 
44 
45 #include "mitkOperationEvent.h"
46 #include "mitkUndoController.h"
48 
50 #include "mitkImageAccessByItk.h"
51 #include "mitkImageCast.h"
52 #include "mitkImageToItk.h"
53 #include "mitkLabelSetImage.h"
54 
55 #define ROUND(a) ((a) > 0 ? (int)((a) + 0.5) : -(int)(0.5 - (a)))
56 
57 bool mitk::SegTool2D::m_SurfaceInterpolationEnabled = true;
58 
59 mitk::SegTool2D::SegTool2D(const char *type, const us::Module *interactorModule)
60  : Tool(type, interactorModule), m_LastEventSender(nullptr), m_LastEventSlice(0), m_Contourmarkername("Position"), m_ShowMarkerNodes(false)
61 {
62  Tool::m_EventConfig = "DisplayConfigMITKNoCrosshair.xml";
63 }
64 
66 {
67 }
68 
70 {
71  const auto *positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
72 
73  bool isValidEvent =
74  (positionEvent && // Only events of type mitk::InteractionPositionEvent
75  interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D // Only events from the 2D renderwindows
76  );
77  return isValidEvent;
78 }
79 
81  const PlaneGeometry *plane,
82  int &affectedDimension,
83  int &affectedSlice)
84 {
85  assert(image);
86  assert(plane);
87 
88  // compare normal of plane to the three axis vectors of the image
89  Vector3D normal = plane->GetNormal();
90  Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0);
91  Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1);
92  Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2);
93 
94  normal.Normalize();
95  imageNormal0.Normalize();
96  imageNormal1.Normalize();
97  imageNormal2.Normalize();
98 
99  imageNormal0.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal0.GetVnlVector()));
100  imageNormal1.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal1.GetVnlVector()));
101  imageNormal2.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal2.GetVnlVector()));
102 
103  double eps(0.00001);
104  // axial
105  if (imageNormal2.GetNorm() <= eps)
106  {
107  affectedDimension = 2;
108  }
109  // sagittal
110  else if (imageNormal1.GetNorm() <= eps)
111  {
112  affectedDimension = 1;
113  }
114  // frontal
115  else if (imageNormal0.GetNorm() <= eps)
116  {
117  affectedDimension = 0;
118  }
119  else
120  {
121  affectedDimension = -1; // no idea
122  return false;
123  }
124 
125  // determine slice number in image
126  BaseGeometry *imageGeometry = image->GetGeometry(0);
127  Point3D testPoint = imageGeometry->GetCenter();
128  Point3D projectedPoint;
129  plane->Project(testPoint, projectedPoint);
130 
131  Point3D indexPoint;
132 
133  imageGeometry->WorldToIndex(projectedPoint, indexPoint);
134  affectedSlice = ROUND(indexPoint[affectedDimension]);
135  MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice "
136  << affectedSlice;
137 
138  // check if this index is still within the image
139  if (affectedSlice < 0 || affectedSlice >= static_cast<int>(image->GetDimension(affectedDimension)))
140  return false;
141 
142  return true;
143 }
144 
146  const Image *workingImage,
147  const PlaneGeometry *plane,
148  bool detectIntersection)
149 {
150  if (!m_SurfaceInterpolationEnabled)
151  return;
152 
154  mitk::Surface::Pointer contour;
155 
156  if (detectIntersection)
157  {
158  // Test whether there is something to extract or whether the slice just contains intersections of others
159  mitk::Image::Pointer slice2 = slice->Clone();
161 
162  contourExtractor->SetInput(slice2);
163  contourExtractor->Update();
164  contour = contourExtractor->GetOutput();
165 
166  if (contour->GetVtkPolyData()->GetNumberOfPoints() == 0)
167  {
168  // Remove contour!
170  contourInfo.contourNormal = plane->GetNormal();
171  contourInfo.contourPoint = plane->GetOrigin();
173  return;
174  }
175  }
176 
177  contourExtractor->SetInput(slice);
178  contourExtractor->Update();
179  contour = contourExtractor->GetOutput();
180 
182  timeSelector->SetInput(workingImage);
183  timeSelector->SetTimeNr(0);
184  timeSelector->SetChannelNr(0);
185  timeSelector->Update();
186  Image::Pointer dimRefImg = timeSelector->GetOutput();
187 
188  if (contour->GetVtkPolyData()->GetNumberOfPoints() != 0 && dimRefImg->GetDimension() == 3)
189  {
191  contour->DisconnectPipeline();
192  }
193  else
194  {
195  // Remove contour!
197  contourInfo.contourNormal = plane->GetNormal();
198  contourInfo.contourPoint = plane->GetOrigin();
200  }
201 }
202 
204 {
205  if (!positionEvent)
206  {
207  return nullptr;
208  }
209 
210  assert(positionEvent->GetSender()); // sure, right?
211  unsigned int timeStep = positionEvent->GetSender()->GetTimeStep(image); // get the timestep of the visible part (time-wise) of the image
212 
213  return GetAffectedImageSliceAs2DImage(positionEvent->GetSender()->GetCurrentWorldPlaneGeometry(), image, timeStep, component);
214 }
215 
216 mitk::Image::Pointer mitk::SegTool2D::GetAffectedImageSliceAs2DImage(const PlaneGeometry *planeGeometry, const Image *image, unsigned int timeStep, unsigned int component /*= 0*/)
217 {
218  if (!image || !planeGeometry)
219  {
220  return nullptr;
221  }
222 
223  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk reslicer
224  vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
225  // set to false to extract a slice
226  reslice->SetOverwriteMode(false);
227  reslice->Modified();
228 
229  // use ExtractSliceFilter with our specific vtkImageReslice for overwriting and extracting
231  extractor->SetInput(image);
232  extractor->SetTimeStep(timeStep);
233  extractor->SetWorldGeometry(planeGeometry);
234  extractor->SetVtkOutputRequest(false);
235  extractor->SetResliceTransformByGeometry(image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep));
236  // additionally extract the given component
237  // default is 0; the extractor checks for multi-component images
238  extractor->SetComponent(component);
239 
240  extractor->Modified();
241  extractor->Update();
242 
243  Image::Pointer slice = extractor->GetOutput();
244 
245  return slice;
246 }
247 
249 {
250  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
251  if (!workingNode)
252  {
253  return nullptr;
254  }
255 
256  auto *workingImage = dynamic_cast<Image *>(workingNode->GetData());
257  if (!workingImage)
258  {
259  return nullptr;
260  }
261 
262  return GetAffectedImageSliceAs2DImage(positionEvent, workingImage);
263 }
264 
266 {
267  DataNode *referenceNode(m_ToolManager->GetReferenceData(0));
268  if (!referenceNode)
269  {
270  return nullptr;
271  }
272 
273  auto *referenceImage = dynamic_cast<Image *>(referenceNode->GetData());
274  if (!referenceImage)
275  {
276  return nullptr;
277  }
278 
279  int displayedComponent = 0;
280  if (referenceNode->GetIntProperty("Image.Displayed Component", displayedComponent))
281  {
282  // found the displayed component
283  return GetAffectedImageSliceAs2DImage(positionEvent, referenceImage, displayedComponent);
284  }
285  else
286  {
287  return GetAffectedImageSliceAs2DImage(positionEvent, referenceImage);
288  }
289 }
290 
292 {
293  if (!positionEvent)
294  return;
295 
296  const PlaneGeometry *planeGeometry((positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()));
297  const auto *abstractTransformGeometry(
298  dynamic_cast<const AbstractTransformGeometry *>(positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()));
299 
300  if (planeGeometry && slice && !abstractTransformGeometry)
301  {
302  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
303  auto *image = dynamic_cast<Image *>(workingNode->GetData());
304  unsigned int timeStep = positionEvent->GetSender()->GetTimeStep(image);
305  this->WriteBackSegmentationResult(planeGeometry, slice, timeStep);
306  }
307 }
308 
310  Image *slice,
311  unsigned int timeStep)
312 {
313  if (!planeGeometry || !slice)
314  return;
315 
316  SliceInformation sliceInfo(slice, const_cast<mitk::PlaneGeometry *>(planeGeometry), timeStep);
317  this->WriteSliceToVolume(sliceInfo);
318  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
319  auto *image = dynamic_cast<Image *>(workingNode->GetData());
320 
321  this->UpdateSurfaceInterpolation(slice, image, planeGeometry, false);
322 
323  if (m_SurfaceInterpolationEnabled)
324  this->AddContourmarker();
325 
327 }
328 
329 void mitk::SegTool2D::WriteBackSegmentationResult(const std::vector<SegTool2D::SliceInformation> &sliceList,
330  bool writeSliceToVolume)
331 {
332  std::vector<mitk::Surface::Pointer> contourList;
333  contourList.reserve(sliceList.size());
335 
336  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
337  auto *image = dynamic_cast<Image *>(workingNode->GetData());
338 
340  timeSelector->SetInput(image);
341  timeSelector->SetTimeNr(0);
342  timeSelector->SetChannelNr(0);
343  timeSelector->Update();
344  Image::Pointer dimRefImg = timeSelector->GetOutput();
345 
346  for (unsigned int i = 0; i < sliceList.size(); ++i)
347  {
348  SliceInformation currentSliceInfo = sliceList.at(i);
349  if (writeSliceToVolume)
350  this->WriteSliceToVolume(currentSliceInfo);
351  if (m_SurfaceInterpolationEnabled && dimRefImg->GetDimension() == 3)
352  {
353  currentSliceInfo.slice->DisconnectPipeline();
354  contourExtractor->SetInput(currentSliceInfo.slice);
355  contourExtractor->Update();
356  mitk::Surface::Pointer contour = contourExtractor->GetOutput();
357  contour->DisconnectPipeline();
358 
359  contourList.push_back(contour);
360  }
361  }
364 }
365 
367 {
368  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
369  auto *image = dynamic_cast<Image *>(workingNode->GetData());
370 
371  /*============= BEGIN undo/redo feature block ========================*/
372  // Create undo operation by caching the not yet modified slices
373  mitk::Image::Pointer originalSlice = GetAffectedImageSliceAs2DImage(sliceInfo.plane, image, sliceInfo.timestep);
374  auto *undoOperation =
375  new DiffSliceOperation(image,
376  originalSlice,
377  dynamic_cast<SlicedGeometry3D *>(originalSlice->GetGeometry()),
378  sliceInfo.timestep,
379  sliceInfo.plane);
380  /*============= END undo/redo feature block ========================*/
381 
382  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk
383  // reslicer
384  vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
385 
386  // Set the slice as 'input'
387  reslice->SetInputSlice(sliceInfo.slice->GetVtkImageData());
388 
389  // set overwrite mode to true to write back to the image volume
390  reslice->SetOverwriteMode(true);
391  reslice->Modified();
392 
394  extractor->SetInput(image);
395  extractor->SetTimeStep(sliceInfo.timestep);
396  extractor->SetWorldGeometry(sliceInfo.plane);
397  extractor->SetVtkOutputRequest(false);
398  extractor->SetResliceTransformByGeometry(image->GetGeometry(sliceInfo.timestep));
399 
400  extractor->Modified();
401  extractor->Update();
402 
403  // the image was modified within the pipeline, but not marked so
404  image->Modified();
405  image->GetVtkImageData()->Modified();
406 
407  // also mark its node as modified (T27308). Can be removed if T27307
408  // is properly solved
409  if (workingNode != nullptr) workingNode->Modified();
410 
411  /*============= BEGIN undo/redo feature block ========================*/
412  // specify the undo operation with the edited slice
413  auto *doOperation =
414  new DiffSliceOperation(image,
415  extractor->GetOutput(),
416  dynamic_cast<SlicedGeometry3D *>(sliceInfo.slice->GetGeometry()),
417  sliceInfo.timestep,
418  sliceInfo.plane);
419 
420  // create an operation event for the undo stack
421  OperationEvent *undoStackItem =
422  new OperationEvent(DiffSliceOperationApplier::GetInstance(), doOperation, undoOperation, "Segmentation");
423 
424  // add it to the undo controller
428 
429  // clear the pointers as the operation are stored in the undocontroller and also deleted from there
430  undoOperation = nullptr;
431  doOperation = nullptr;
432  /*============= END undo/redo feature block ========================*/
433 }
434 
436 {
437  m_ShowMarkerNodes = status;
438 }
439 
441 {
442  m_SurfaceInterpolationEnabled = enabled;
443 }
444 
446 {
447  if (m_LastEventSender == nullptr)
448  return -1;
449 
453 
454  unsigned int slicePosition = m_LastEventSender->GetSliceNavigationController()->GetSlice()->GetPos();
455 
456  // the first geometry is needed otherwise restoring the position is not working
457  const auto *plane =
458  dynamic_cast<const PlaneGeometry *>(dynamic_cast<const mitk::SlicedGeometry3D *>(
460  ->GetPlaneGeometry(0));
461 
462  unsigned int size = service->GetNumberOfPlanePositions();
463  unsigned int id = service->AddNewPlanePosition(plane, slicePosition);
464 
466  mitk::Point2D p1;
467  plane->Map(plane->GetCenter(), p1);
468  mitk::Point2D p2 = p1;
469  p2[0] -= plane->GetSpacing()[0];
470  p2[1] -= plane->GetSpacing()[1];
471  contourMarker->PlaceFigure(p1);
472  contourMarker->SetCurrentControlPoint(p1);
473  contourMarker->SetPlaneGeometry(const_cast<PlaneGeometry *>(plane));
474 
475  std::stringstream markerStream;
476  mitk::DataNode *workingNode(m_ToolManager->GetWorkingData(0));
477 
478  markerStream << m_Contourmarkername;
479  markerStream << " ";
480  markerStream << id + 1;
481 
482  DataNode::Pointer rotatedContourNode = DataNode::New();
483 
484  rotatedContourNode->SetData(contourMarker);
485  rotatedContourNode->SetProperty("name", StringProperty::New(markerStream.str()));
486  rotatedContourNode->SetProperty("isContourMarker", BoolProperty::New(true));
487  rotatedContourNode->SetBoolProperty("PlanarFigureInitializedWindow", true, m_LastEventSender);
488  rotatedContourNode->SetProperty("includeInBoundingBox", BoolProperty::New(false));
489  rotatedContourNode->SetProperty("helper object", mitk::BoolProperty::New(!m_ShowMarkerNodes));
490  rotatedContourNode->SetProperty("planarfigure.drawcontrolpoints", BoolProperty::New(false));
491  rotatedContourNode->SetProperty("planarfigure.drawname", BoolProperty::New(false));
492  rotatedContourNode->SetProperty("planarfigure.drawoutline", BoolProperty::New(false));
493  rotatedContourNode->SetProperty("planarfigure.drawshadow", BoolProperty::New(false));
494 
495  if (plane)
496  {
497  if (id == size)
498  {
499  m_ToolManager->GetDataStorage()->Add(rotatedContourNode, workingNode);
500  }
501  else
502  {
505 
506  mitk::DataStorage::SetOfObjects::ConstPointer markers =
507  m_ToolManager->GetDataStorage()->GetDerivations(workingNode, isMarker);
508 
509  for (auto iter = markers->begin(); iter != markers->end(); ++iter)
510  {
511  std::string nodeName = (*iter)->GetName();
512  unsigned int t = nodeName.find_last_of(" ");
513  unsigned int markerId = atof(nodeName.substr(t + 1).c_str()) - 1;
514  if (id == markerId)
515  {
516  return id;
517  }
518  }
519  m_ToolManager->GetDataStorage()->Add(rotatedContourNode, workingNode);
520  }
521  }
522  return id;
523 }
524 
526 {
527  MITK_ERROR << "********************************************************************************" << std::endl
528  << " " << message << std::endl
529  << "********************************************************************************" << std::endl
530  << " " << std::endl
531  << " If your image is rotated or the 2D views don't really contain the patient image, try to press the "
532  "button next to the image selection. "
533  << std::endl
534  << " " << std::endl
535  << " Please file a BUG REPORT: " << std::endl
536  << " https://phabricator.mitk.org/" << std::endl
537  << " Contain the following information:" << std::endl
538  << " - What image were you working on?" << std::endl
539  << " - Which region of the image?" << std::endl
540  << " - Which tool did you use?" << std::endl
541  << " - What did you do?" << std::endl
542  << " - What happened (not)? What did you expect?" << std::endl;
543 }
544 
545 template <typename TPixel, unsigned int VImageDimension>
546 void InternalWritePreviewOnWorkingImage(itk::Image<TPixel, VImageDimension> *targetSlice,
547  const mitk::Image *sourceSlice,
548  mitk::Image *originalImage,
549  int overwritevalue)
550 {
551  typedef itk::Image<TPixel, VImageDimension> SliceType;
552 
553  typename SliceType::Pointer sourceSliceITK;
554  CastToItkImage(sourceSlice, sourceSliceITK);
555 
556  // now the original slice and the ipSegmentation-painted slice are in the same format, and we can just copy all pixels
557  // that are non-zero
558  typedef itk::ImageRegionIterator<SliceType> OutputIteratorType;
559  typedef itk::ImageRegionConstIterator<SliceType> InputIteratorType;
560 
561  InputIteratorType inputIterator(sourceSliceITK, sourceSliceITK->GetLargestPossibleRegion());
562  OutputIteratorType outputIterator(targetSlice, targetSlice->GetLargestPossibleRegion());
563 
564  outputIterator.GoToBegin();
565  inputIterator.GoToBegin();
566 
567  auto *workingImage = dynamic_cast<mitk::LabelSetImage *>(originalImage);
568  assert(workingImage);
569 
570  int activePixelValue = workingImage->GetActiveLabel()->GetValue();
571 
572  if (activePixelValue == 0) // if exterior is the active label
573  {
574  while (!outputIterator.IsAtEnd())
575  {
576  if (inputIterator.Get() != 0)
577  {
578  outputIterator.Set(overwritevalue);
579  }
580  ++outputIterator;
581  ++inputIterator;
582  }
583  }
584  else if (overwritevalue != 0) // if we are not erasing
585  {
586  while (!outputIterator.IsAtEnd())
587  {
588  auto targetValue = static_cast<int>(outputIterator.Get());
589  if (inputIterator.Get() != 0)
590  {
591  if (!workingImage->GetLabel(targetValue)->GetLocked())
592  {
593  outputIterator.Set(overwritevalue);
594  }
595  }
596  if (targetValue == overwritevalue)
597  {
598  outputIterator.Set(inputIterator.Get());
599  }
600 
601  ++outputIterator;
602  ++inputIterator;
603  }
604  }
605  else // if we are erasing
606  {
607  while (!outputIterator.IsAtEnd())
608  {
609  const int targetValue = outputIterator.Get();
610  if (inputIterator.Get() != 0)
611  {
612  if (targetValue == activePixelValue)
613  outputIterator.Set(overwritevalue);
614  }
615 
616  ++outputIterator;
617  ++inputIterator;
618  }
619  }
620 }
621 
623  Image *targetSlice, Image *sourceSlice, mitk::Image *workingImage, int paintingPixelValue, int)
624 {
625  if ((!targetSlice) || (!sourceSlice))
626  return;
628  targetSlice, InternalWritePreviewOnWorkingImage, 2, sourceSlice, workingImage, paintingPixelValue);
629 }
Pointer Clone() const
ServiceReferenceU GetServiceReference(const std::string &clazz)
mitk::Stepper * GetSlice()
Get the Stepper through the slices.
~SegTool2D() override
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:86
Super class for all position events.
virtual SetOfObjects::ConstPointer GetDerivations(const DataNode *node, const NodePredicateBase *condition=nullptr, bool onlyDirectDerivations=true) const =0
returns a set of derived objects for a given node.
Image::Pointer GetAffectedImageSliceAs2DImage(const InteractionPositionEvent *positionEvent, const Image *image, unsigned int component=0)
Extract the slice of an image that the user just scribbles on. The given component denotes the vector...
DataStorage * GetDataStorage()
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
#define MITK_ERROR
Definition: mitkLogMacros.h:20
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
static Pointer New()
An Operation for applying an edited slice to the volume.
bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode) override
Filters events that cannot be handle by 2D segmentation tools.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
void WriteSliceToVolume(const SliceInformation &sliceInfo)
BaseRenderer * m_LastEventSender
Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *)
Extract the slice of the currently selected reference image that the user just scribbles on...
Point3D GetCenter() const
Get the center of the bounding-box in mm.
virtual bool Project(const mitk::Point3D &pt3d_mm, mitk::Point3D &projectedPt3d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 3D point in mm (projec...
virtual void Add(DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
Adds a DataNode containing a data object to its internal storage.
void InternalWritePreviewOnWorkingImage(itk::Image< TPixel, VImageDimension > *targetSlice, const mitk::Image *sourceSlice, mitk::Image *originalImage, int overwritevalue)
void * GetService(const ServiceReferenceBase &reference)
std::string m_EventConfig
Let subclasses change their event configuration.
Definition: mitkTool.h:218
#define AccessFixedDimensionByItk_3(mitkImage, itkImageTypeFunction, dimension, arg1, arg2, arg3)
void SetEnable3DInterpolation(bool)
Enables or disables the 3D interpolation after writing back the 2D segmentation result, and defaults to true.
void InteractiveSegmentationBugMessage(const std::string &message)
BaseRenderer * GetSender() const
static Pointer New()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
unsigned int GetDimension() const
Get dimension of the image.
Definition: mitkImage.cpp:106
static Pointer New()
void SetShowMarkerNodes(bool)
static RenderingManager * GetInstance()
virtual unsigned int GetTimeStep() const
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
Image class for storing images.
Definition: mitkImage.h:72
void WriteBackSegmentationResult(const InteractionPositionEvent *, Image *)
SlicedGeometry3D * GetSlicedGeometry(unsigned int t=0) const
Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it)...
#define ROUND(a)
void AddNewContours(std::vector< Surface::Pointer > newContours)
Adds new extracted contours to the list. If one or more contours at a given position already exist th...
mitk::Image::Pointer image
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
static Pointer New(const char *_arg)
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
Describes the geometry of a data object consisting of slices.
bool RemoveContour(ContourPositionInformation contourInfo)
Removes the contour for a given plane for the current selected segmenation.
static void UpdateSurfaceInterpolation(const Image *slice, const Image *workingImage, const PlaneGeometry *plane, bool detectIntersection)
Updates the surface interpolation by extracting the contour form the given slice. ...
Vector3D GetNormal() const
Normal of the plane.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static SurfaceInterpolationController * GetInstance()
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
virtual bool SetOperationEvent(UndoStackItem *stackItem)=0
static UndoModel * GetCurrentUndoModel()
gives access to the currently used UndoModel Introduced to access special functions of more specific ...
void WritePreviewOnWorkingImage(Image *targetSlice, Image *sourceSlice, Image *workingImage, int paintingPixelValue, int timestep)
DataVectorType GetReferenceData()
LabelSetImage class for handling labels and layers in a segmentation session.
ToolManager * m_ToolManager
Definition: mitkTool.h:228
MITKCORE_EXPORT const ScalarType eps
virtual SliceNavigationController * GetSliceNavigationController()
virtual unsigned int GetPos() const
Describes a two-dimensional, rectangular plane.
static void IncCurrObjectEventId()
Increases the current ObjectEventId For example if a button click generates operations the ObjectEven...
const mitk::BaseGeometry * GetCurrentGeometry3D()
Returns the BaseGeometry of the currently selected time step.
void AddNewContour(Surface::Pointer newContour)
Adds a new extracted contour to the list.
static Pointer New()
int AddContourmarker()
Adds a new node called Contourmarker to the datastorage which holds a mitk::PlanarFigure. By selecting this node the slicestack will be reoriented according to the PlanarFigure&#39;s Geometry.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
static void IncCurrGroupEventId()
Increases the current GroupEventId For example if a button click generates operations the GroupEventI...
static Pointer New()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
Image::Pointer GetAffectedWorkingSlice(const InteractionPositionEvent *)
Extract the slice of the currently selected working image that the user just scribbles on...
Represents a pair of operations: undo and the according redo.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
static Pointer New()
DataVectorType GetWorkingData()
static void Erode(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Perform morphological operation on 2D, 3D or 3D+t segmentation.
static bool DetermineAffectedImageSlice(const Image *image, const PlaneGeometry *plane, int &affectedDimension, int &affectedSlice)
Calculates for a given Image and PlaneGeometry, which slice of the image (in index corrdinates) is me...