Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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  /*============= BEGIN undo/redo feature block ========================*/
408  // specify the undo operation with the edited slice
409  auto *doOperation =
410  new DiffSliceOperation(image,
411  extractor->GetOutput(),
412  dynamic_cast<SlicedGeometry3D *>(sliceInfo.slice->GetGeometry()),
413  sliceInfo.timestep,
414  sliceInfo.plane);
415 
416  // create an operation event for the undo stack
417  OperationEvent *undoStackItem =
418  new OperationEvent(DiffSliceOperationApplier::GetInstance(), doOperation, undoOperation, "Segmentation");
419 
420  // add it to the undo controller
424 
425  // clear the pointers as the operation are stored in the undocontroller and also deleted from there
426  undoOperation = nullptr;
427  doOperation = nullptr;
428  /*============= END undo/redo feature block ========================*/
429 }
430 
432 {
433  m_ShowMarkerNodes = status;
434 }
435 
437 {
438  m_SurfaceInterpolationEnabled = enabled;
439 }
440 
442 {
443  if (m_LastEventSender == nullptr)
444  return -1;
445 
449 
450  unsigned int slicePosition = m_LastEventSender->GetSliceNavigationController()->GetSlice()->GetPos();
451 
452  // the first geometry is needed otherwise restoring the position is not working
453  const auto *plane =
454  dynamic_cast<const PlaneGeometry *>(dynamic_cast<const mitk::SlicedGeometry3D *>(
456  ->GetPlaneGeometry(0));
457 
458  unsigned int size = service->GetNumberOfPlanePositions();
459  unsigned int id = service->AddNewPlanePosition(plane, slicePosition);
460 
462  mitk::Point2D p1;
463  plane->Map(plane->GetCenter(), p1);
464  mitk::Point2D p2 = p1;
465  p2[0] -= plane->GetSpacing()[0];
466  p2[1] -= plane->GetSpacing()[1];
467  contourMarker->PlaceFigure(p1);
468  contourMarker->SetCurrentControlPoint(p1);
469  contourMarker->SetPlaneGeometry(const_cast<PlaneGeometry *>(plane));
470 
471  std::stringstream markerStream;
472  mitk::DataNode *workingNode(m_ToolManager->GetWorkingData(0));
473 
474  markerStream << m_Contourmarkername;
475  markerStream << " ";
476  markerStream << id + 1;
477 
478  DataNode::Pointer rotatedContourNode = DataNode::New();
479 
480  rotatedContourNode->SetData(contourMarker);
481  rotatedContourNode->SetProperty("name", StringProperty::New(markerStream.str()));
482  rotatedContourNode->SetProperty("isContourMarker", BoolProperty::New(true));
483  rotatedContourNode->SetBoolProperty("PlanarFigureInitializedWindow", true, m_LastEventSender);
484  rotatedContourNode->SetProperty("includeInBoundingBox", BoolProperty::New(false));
485  rotatedContourNode->SetProperty("helper object", mitk::BoolProperty::New(!m_ShowMarkerNodes));
486  rotatedContourNode->SetProperty("planarfigure.drawcontrolpoints", BoolProperty::New(false));
487  rotatedContourNode->SetProperty("planarfigure.drawname", BoolProperty::New(false));
488  rotatedContourNode->SetProperty("planarfigure.drawoutline", BoolProperty::New(false));
489  rotatedContourNode->SetProperty("planarfigure.drawshadow", BoolProperty::New(false));
490 
491  if (plane)
492  {
493  if (id == size)
494  {
495  m_ToolManager->GetDataStorage()->Add(rotatedContourNode, workingNode);
496  }
497  else
498  {
501 
502  mitk::DataStorage::SetOfObjects::ConstPointer markers =
503  m_ToolManager->GetDataStorage()->GetDerivations(workingNode, isMarker);
504 
505  for (auto iter = markers->begin(); iter != markers->end(); ++iter)
506  {
507  std::string nodeName = (*iter)->GetName();
508  unsigned int t = nodeName.find_last_of(" ");
509  unsigned int markerId = atof(nodeName.substr(t + 1).c_str()) - 1;
510  if (id == markerId)
511  {
512  return id;
513  }
514  }
515  m_ToolManager->GetDataStorage()->Add(rotatedContourNode, workingNode);
516  }
517  }
518  return id;
519 }
520 
522 {
523  MITK_ERROR << "********************************************************************************" << std::endl
524  << " " << message << std::endl
525  << "********************************************************************************" << std::endl
526  << " " << std::endl
527  << " If your image is rotated or the 2D views don't really contain the patient image, try to press the "
528  "button next to the image selection. "
529  << std::endl
530  << " " << std::endl
531  << " Please file a BUG REPORT: " << std::endl
532  << " https://phabricator.mitk.org/" << std::endl
533  << " Contain the following information:" << std::endl
534  << " - What image were you working on?" << std::endl
535  << " - Which region of the image?" << std::endl
536  << " - Which tool did you use?" << std::endl
537  << " - What did you do?" << std::endl
538  << " - What happened (not)? What did you expect?" << std::endl;
539 }
540 
541 template <typename TPixel, unsigned int VImageDimension>
542 void InternalWritePreviewOnWorkingImage(itk::Image<TPixel, VImageDimension> *targetSlice,
543  const mitk::Image *sourceSlice,
544  mitk::Image *originalImage,
545  int overwritevalue)
546 {
547  typedef itk::Image<TPixel, VImageDimension> SliceType;
548 
549  typename SliceType::Pointer sourceSliceITK;
550  CastToItkImage(sourceSlice, sourceSliceITK);
551 
552  // now the original slice and the ipSegmentation-painted slice are in the same format, and we can just copy all pixels
553  // that are non-zero
554  typedef itk::ImageRegionIterator<SliceType> OutputIteratorType;
555  typedef itk::ImageRegionConstIterator<SliceType> InputIteratorType;
556 
557  InputIteratorType inputIterator(sourceSliceITK, sourceSliceITK->GetLargestPossibleRegion());
558  OutputIteratorType outputIterator(targetSlice, targetSlice->GetLargestPossibleRegion());
559 
560  outputIterator.GoToBegin();
561  inputIterator.GoToBegin();
562 
563  auto *workingImage = dynamic_cast<mitk::LabelSetImage *>(originalImage);
564  assert(workingImage);
565 
566  int activePixelValue = workingImage->GetActiveLabel()->GetValue();
567 
568  if (activePixelValue == 0) // if exterior is the active label
569  {
570  while (!outputIterator.IsAtEnd())
571  {
572  if (inputIterator.Get() != 0)
573  {
574  outputIterator.Set(overwritevalue);
575  }
576  ++outputIterator;
577  ++inputIterator;
578  }
579  }
580  else if (overwritevalue != 0) // if we are not erasing
581  {
582  while (!outputIterator.IsAtEnd())
583  {
584  auto targetValue = static_cast<int>(outputIterator.Get());
585  if (inputIterator.Get() != 0)
586  {
587  if (!workingImage->GetLabel(targetValue)->GetLocked())
588  {
589  outputIterator.Set(overwritevalue);
590  }
591  }
592  if (targetValue == overwritevalue)
593  {
594  outputIterator.Set(inputIterator.Get());
595  }
596 
597  ++outputIterator;
598  ++inputIterator;
599  }
600  }
601  else // if we are erasing
602  {
603  while (!outputIterator.IsAtEnd())
604  {
605  const int targetValue = outputIterator.Get();
606  if (inputIterator.Get() != 0)
607  {
608  if (targetValue == activePixelValue)
609  outputIterator.Set(overwritevalue);
610  }
611 
612  ++outputIterator;
613  ++inputIterator;
614  }
615  }
616 }
617 
619  Image *targetSlice, Image *sourceSlice, mitk::Image *workingImage, int paintingPixelValue, int)
620 {
621  if ((!targetSlice) || (!sourceSlice))
622  return;
624  targetSlice, InternalWritePreviewOnWorkingImage, 2, sourceSlice, workingImage, paintingPixelValue);
625 }
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:88
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:220
#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:230
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:64
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...