Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkSegTool2D.h"
18 #include "mitkToolManager.h"
19 
20 #include "mitkBaseRenderer.h"
21 #include "mitkDataStorage.h"
22 
23 #include "mitkPlaneGeometry.h"
24 
26 #include "mitkExtractImageFilter.h"
27 
28 // Include of the new ImageExtractor
33 #include "mitkPlanarCircle.h"
34 
35 #include "usGetModuleContext.h"
36 
37 // Includes for 3DSurfaceInterpolation
38 #include "mitkImageTimeSelector.h"
41 
42 // includes for resling and overwriting
43 #include <mitkExtractSliceFilter.h>
44 #include <mitkVtkImageOverwrite.h>
45 #include <vtkImageData.h>
46 #include <vtkSmartPointer.h>
47 
48 
49 #include "mitkOperationEvent.h"
50 #include "mitkUndoController.h"
52 
54 #include "mitkImageAccessByItk.h"
55 #include "mitkImageCast.h"
56 #include "mitkImageToItk.h"
57 #include "mitkLabelSetImage.h"
58 
59 #define ROUND(a) ((a) > 0 ? (int)((a) + 0.5) : -(int)(0.5 - (a)))
60 
61 bool mitk::SegTool2D::m_SurfaceInterpolationEnabled = true;
62 
63 mitk::SegTool2D::SegTool2D(const char *type)
64  : Tool(type), m_LastEventSender(NULL), m_LastEventSlice(0), m_Contourmarkername("Position"), m_ShowMarkerNodes(false)
65 {
66  Tool::m_EventConfig = "DisplayConfigMITKNoCrosshair.xml";
67 }
68 
70 {
71 }
72 
74 {
75  const InteractionPositionEvent *positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
76 
77  bool isValidEvent =
78  (positionEvent && // Only events of type mitk::InteractionPositionEvent
79  interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D // Only events from the 2D renderwindows
80  );
81  return isValidEvent;
82 }
83 
85  const PlaneGeometry *plane,
86  int &affectedDimension,
87  int &affectedSlice)
88 {
89  assert(image);
90  assert(plane);
91 
92  // compare normal of plane to the three axis vectors of the image
93  Vector3D normal = plane->GetNormal();
94  Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0);
95  Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1);
96  Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2);
97 
98  normal.Normalize();
99  imageNormal0.Normalize();
100  imageNormal1.Normalize();
101  imageNormal2.Normalize();
102 
103  imageNormal0.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal0.GetVnlVector()));
104  imageNormal1.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal1.GetVnlVector()));
105  imageNormal2.SetVnlVector(vnl_cross_3d<ScalarType>(normal.GetVnlVector(), imageNormal2.GetVnlVector()));
106 
107  double eps(0.00001);
108  // axial
109  if (imageNormal2.GetNorm() <= eps)
110  {
111  affectedDimension = 2;
112  }
113  // sagittal
114  else if (imageNormal1.GetNorm() <= eps)
115  {
116  affectedDimension = 1;
117  }
118  // frontal
119  else if (imageNormal0.GetNorm() <= eps)
120  {
121  affectedDimension = 0;
122  }
123  else
124  {
125  affectedDimension = -1; // no idea
126  return false;
127  }
128 
129  // determine slice number in image
130  BaseGeometry *imageGeometry = image->GetGeometry(0);
131  Point3D testPoint = imageGeometry->GetCenter();
132  Point3D projectedPoint;
133  plane->Project(testPoint, projectedPoint);
134 
135  Point3D indexPoint;
136 
137  imageGeometry->WorldToIndex(projectedPoint, indexPoint);
138  affectedSlice = ROUND(indexPoint[affectedDimension]);
139  MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice "
140  << affectedSlice;
141 
142  // check if this index is still within the image
143  if (affectedSlice < 0 || affectedSlice >= static_cast<int>(image->GetDimension(affectedDimension)))
144  return false;
145 
146  return true;
147 }
148 
150  const Image *workingImage,
151  const PlaneGeometry *plane,
152  bool detectIntersection)
153 {
154  if (!m_SurfaceInterpolationEnabled)
155  return;
156 
158  mitk::Surface::Pointer contour;
159 
160  if (detectIntersection)
161  {
162  // Test whether there is something to extract or whether the slice just contains intersections of others
163  mitk::Image::Pointer slice2 = slice->Clone();
165 
166  contourExtractor->SetInput(slice2);
167  contourExtractor->Update();
168  contour = contourExtractor->GetOutput();
169 
170  if (contour->GetVtkPolyData()->GetNumberOfPoints() == 0)
171  {
172  // Remove contour!
174  contourInfo.contourNormal = plane->GetNormal();
175  contourInfo.contourPoint = plane->GetOrigin();
177  return;
178  }
179  }
180 
181  contourExtractor->SetInput(slice);
182  contourExtractor->Update();
183  contour = contourExtractor->GetOutput();
184 
186  timeSelector->SetInput(workingImage);
187  timeSelector->SetTimeNr(0);
188  timeSelector->SetChannelNr(0);
189  timeSelector->Update();
190  Image::Pointer dimRefImg = timeSelector->GetOutput();
191 
192  if (contour->GetVtkPolyData()->GetNumberOfPoints() != 0 && dimRefImg->GetDimension() == 3)
193  {
195  contour->DisconnectPipeline();
196  }
197  else
198  {
199  // Remove contour!
201  contourInfo.contourNormal = plane->GetNormal();
202  contourInfo.contourPoint = plane->GetOrigin();
204  }
205 }
206 
207 mitk::Image::Pointer mitk::SegTool2D::GetAffectedImageSliceAs2DImage(const InteractionPositionEvent *positionEvent, const Image *image, unsigned int component /*= 0*/)
208 {
209  if (!positionEvent)
210  {
211  return nullptr;
212  }
213 
214  assert(positionEvent->GetSender()); // sure, right?
215  unsigned int timeStep = positionEvent->GetSender()->GetTimeStep(image); // get the timestep of the visible part (time-wise) of the image
216 
217  return GetAffectedImageSliceAs2DImage(positionEvent->GetSender()->GetCurrentWorldPlaneGeometry(), image, timeStep, component);
218 }
219 
220 mitk::Image::Pointer mitk::SegTool2D::GetAffectedImageSliceAs2DImage(const PlaneGeometry *planeGeometry, const Image *image, unsigned int timeStep, unsigned int component /*= 0*/)
221 {
222  if (!image || !planeGeometry)
223  {
224  return nullptr;
225  }
226 
227  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk reslicer
228  vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
229  // set to false to extract a slice
230  reslice->SetOverwriteMode(false);
231  reslice->Modified();
232 
233  // use ExtractSliceFilter with our specific vtkImageReslice for overwriting and extracting
235  extractor->SetInput(image);
236  extractor->SetTimeStep(timeStep);
237  extractor->SetWorldGeometry(planeGeometry);
238  extractor->SetVtkOutputRequest(false);
239  extractor->SetResliceTransformByGeometry(image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep));
240  // additionally extract the given component
241  // default is 0; the extractor checks for multi-component images
242  extractor->SetComponent(component);
243 
244  extractor->Modified();
245  extractor->Update();
246 
247  Image::Pointer slice = extractor->GetOutput();
248 
249  return slice;
250 }
251 
253 {
254  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
255  if (!workingNode)
256  {
257  return nullptr;
258  }
259 
260  Image *workingImage = dynamic_cast<Image *>(workingNode->GetData());
261  if (!workingImage)
262  {
263  return nullptr;
264  }
265 
266  return GetAffectedImageSliceAs2DImage(positionEvent, workingImage);
267 }
268 
270 {
271  DataNode *referenceNode(m_ToolManager->GetReferenceData(0));
272  if (!referenceNode)
273  {
274  return nullptr;
275  }
276 
277  Image *referenceImage = dynamic_cast<Image *>(referenceNode->GetData());
278  if (!referenceImage)
279  {
280  return nullptr;
281  }
282 
283  int displayedComponent = 0;
284  if (referenceNode->GetIntProperty("Image.Displayed Component", displayedComponent))
285  {
286  // found the displayed component
287  return GetAffectedImageSliceAs2DImage(positionEvent, referenceImage, displayedComponent);
288  }
289  else
290  {
291  return GetAffectedImageSliceAs2DImage(positionEvent, referenceImage);
292  }
293 }
294 
296 {
297  if (!positionEvent)
298  return;
299 
300  const PlaneGeometry *planeGeometry((positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()));
301  const AbstractTransformGeometry *abstractTransformGeometry(
302  dynamic_cast<const AbstractTransformGeometry *>(positionEvent->GetSender()->GetCurrentWorldPlaneGeometry()));
303 
304  if (planeGeometry && slice && !abstractTransformGeometry)
305  {
306  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
307  Image *image = dynamic_cast<Image *>(workingNode->GetData());
308  unsigned int timeStep = positionEvent->GetSender()->GetTimeStep(image);
309  this->WriteBackSegmentationResult(planeGeometry, slice, timeStep);
310  }
311 }
312 
314  Image *slice,
315  unsigned int timeStep)
316 {
317  if (!planeGeometry || !slice)
318  return;
319 
320  SliceInformation sliceInfo(slice, const_cast<mitk::PlaneGeometry *>(planeGeometry), timeStep);
321  this->WriteSliceToVolume(sliceInfo);
322  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
323  Image *image = dynamic_cast<Image *>(workingNode->GetData());
324 
325  this->UpdateSurfaceInterpolation(slice, image, planeGeometry, false);
326 
327  if (m_SurfaceInterpolationEnabled)
328  this->AddContourmarker();
329 
331 }
332 
333 void mitk::SegTool2D::WriteBackSegmentationResult(std::vector<mitk::SegTool2D::SliceInformation> sliceList,
334  bool writeSliceToVolume)
335 {
336  std::vector<mitk::Surface::Pointer> contourList;
337  contourList.reserve(sliceList.size());
339 
340  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
341  Image *image = dynamic_cast<Image *>(workingNode->GetData());
342 
344  timeSelector->SetInput(image);
345  timeSelector->SetTimeNr(0);
346  timeSelector->SetChannelNr(0);
347  timeSelector->Update();
348  Image::Pointer dimRefImg = timeSelector->GetOutput();
349 
350  for (unsigned int i = 0; i < sliceList.size(); ++i)
351  {
352  SliceInformation currentSliceInfo = sliceList.at(i);
353  if (writeSliceToVolume)
354  this->WriteSliceToVolume(currentSliceInfo);
355  if (m_SurfaceInterpolationEnabled && dimRefImg->GetDimension() == 3)
356  {
357  currentSliceInfo.slice->DisconnectPipeline();
358  contourExtractor->SetInput(currentSliceInfo.slice);
359  contourExtractor->Update();
360  mitk::Surface::Pointer contour = contourExtractor->GetOutput();
361  contour->DisconnectPipeline();
362 
363  contourList.push_back(contour);
364  }
365  }
368 }
369 
371 {
372  DataNode *workingNode(m_ToolManager->GetWorkingData(0));
373  Image *image = dynamic_cast<Image *>(workingNode->GetData());
374 
375  /*============= BEGIN undo/redo feature block ========================*/
376  // Create undo operation by caching the not yet modified slices
377  mitk::Image::Pointer originalSlice = GetAffectedImageSliceAs2DImage(sliceInfo.plane, image, sliceInfo.timestep);
378  DiffSliceOperation *undoOperation =
379  new DiffSliceOperation(const_cast<mitk::Image *>(image),
380  originalSlice,
381  dynamic_cast<SlicedGeometry3D *>(originalSlice->GetGeometry()),
382  sliceInfo.timestep,
383  sliceInfo.plane);
384  /*============= END undo/redo feature block ========================*/
385 
386  // Make sure that for reslicing and overwriting the same alogrithm is used. We can specify the mode of the vtk
387  // reslicer
388  vtkSmartPointer<mitkVtkImageOverwrite> reslice = vtkSmartPointer<mitkVtkImageOverwrite>::New();
389 
390  // Set the slice as 'input'
391  reslice->SetInputSlice(sliceInfo.slice->GetVtkImageData());
392 
393  // set overwrite mode to true to write back to the image volume
394  reslice->SetOverwriteMode(true);
395  reslice->Modified();
396 
398  extractor->SetInput(image);
399  extractor->SetTimeStep(sliceInfo.timestep);
400  extractor->SetWorldGeometry(sliceInfo.plane);
401  extractor->SetVtkOutputRequest(false);
402  extractor->SetResliceTransformByGeometry(image->GetGeometry(sliceInfo.timestep));
403 
404  extractor->Modified();
405  extractor->Update();
406 
407  // the image was modified within the pipeline, but not marked so
408  image->Modified();
409  image->GetVtkImageData()->Modified();
410 
411  /*============= BEGIN undo/redo feature block ========================*/
412  // specify the undo operation with the edited slice
413  DiffSliceOperation *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 = NULL;
431  doOperation = NULL;
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 == NULL)
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 mitk::PlaneGeometry *plane =
458  dynamic_cast<const PlaneGeometry *>(dynamic_cast<const mitk::SlicedGeometry3D *>(
459  m_LastEventSender->GetSliceNavigationController()->GetCurrentGeometry3D())
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 
507  m_ToolManager->GetDataStorage()->GetDerivations(workingNode, isMarker);
508 
509  for (mitk::DataStorage::SetOfObjects::const_iterator 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  mitk::LabelSetImage *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  int 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 timestep)
624 {
625  if ((!targetSlice) || (!sourceSlice))
626  return;
628  targetSlice, InternalWritePreviewOnWorkingImage, 2, sourceSlice, workingImage, paintingPixelValue);
629 }
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
ServiceReferenceU GetServiceReference(const std::string &clazz)
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:92
Super class for all position events.
itk::SmartPointer< Self > Pointer
BaseRenderer * GetSender() const
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...
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
#define MITK_ERROR
Definition: mitkLogMacros.h:24
void WriteSliceToVolume(SliceInformation sliceInfo)
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
static Pointer New()
mitk::Label * GetLabel(PixelType pixelValue, unsigned int layer=0) const
Returns the mitk::Label with the given pixelValue and for the given layer.
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
An Operation for applying an edited slice to the volume.
virtual 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.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:52
Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *)
Extract the slice of the currently selected reference image that the user just scribbles on...
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:224
#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.
Vector3D GetNormal() const
Normal of the plane.
itk::SmartPointer< const Self > ConstPointer
void InteractiveSegmentationBugMessage(const std::string &message)
static Pointer New()
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
static Pointer New()
void SetShowMarkerNodes(bool)
static RenderingManager * GetInstance()
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
Image class for storing images.
Definition: mitkImage.h:76
bool GetLocked() const
Definition: mitkLabel.cpp:105
void WriteBackSegmentationResult(const InteractionPositionEvent *, Image *)
#define ROUND(a)
mitk::Label * GetActiveLabel(unsigned int layer=0)
Returns the active label of a specific layer.
Describes a geometry defined by an vtkAbstractTransform and a plane.
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...
Point3D GetCenter() const
Get the center of the bounding-box in mm.
static Pointer New(const char *_arg)
Describes the geometry of a data object consisting of slices.
virtual ~SegTool2D()
virtual unsigned int GetTimeStep() const
bool RemoveContour(ContourPositionInformation contourInfo)
Removes the contour for a given plane for the current selected segmenation.
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...
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. ...
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)
LabelSetImage class for handling labels and layers in a segmentation session.
MITKCORE_EXPORT const ScalarType eps
SlicedGeometry3D * GetSlicedGeometry(unsigned int t=0) const
Convenience access method for the geometry, which is of type SlicedGeometry3D (or a sub-class of it)...
Describes a two-dimensional, rectangular plane.
static void IncCurrObjectEventId()
Increases the current ObjectEventId For example if a button click generates operations the ObjectEven...
void AddNewContour(Surface::Pointer newContour)
Adds a new extracted contour to the list.
static Pointer New()
PixelType GetValue() const
Definition: mitkLabel.cpp:171
unsigned int GetDimension() const
Get dimension of the image.
Definition: mitkImage.cpp:110
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'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:129
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:66
static Pointer New()
Pointer Clone() const
static void Erode(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Perform morphological operation on 2D, 3D or 3D+t segmentation.
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
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...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.