Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkAutoCropTool.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 "mitkAutoCropTool.h"
14 
15 #include "mitkAutoCropTool.xpm"
16 
18 
19 namespace mitk
20 {
22 }
23 
25 {
26 }
27 
29 {
30 }
31 
32 const char **mitk::AutoCropTool::GetXPM() const
33 {
34  return mitkAutoCropTool_xpm;
35 }
36 
37 const char *mitk::AutoCropTool::GetName() const
38 {
39  return "Crop";
40 }
41 
43 {
44  return "Cropping of these nodes failed:";
45 }
46 
48 {
49  if (node)
50  {
51  Image::Pointer image = dynamic_cast<Image *>(node->GetData());
52  if (image.IsNull())
53  return false;
54 
55  // if (image->GetDimension() == 4)
56  // {
57  // Tool::ErrorMessage.Send("Cropping 3D+t segmentations is not implemented. Sorry. Bug #1281");
58  // return false;
59  // }
60 
62  cropFilter->SetInput(image);
63  cropFilter->SetBackgroundValue(0);
64  try
65  {
66  cropFilter->Update();
67 
68  image = cropFilter->GetOutput();
69  if (image.IsNotNull())
70  {
71  node->SetData(image);
72  }
73  else
74  {
75  return false;
76  }
77  }
78  catch (...)
79  {
80  return false;
81  }
82  }
83 
84  return true;
85 }
bool ProcessOneWorkingData(DataNode *node) override
Subclasses should override this method.
Shrink the image borders to a minimum considering a background color.
virtual void SetData(mitk::BaseData *baseData)
Set the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
const char ** GetXPM() const override
Returns an icon in the XPM format.
std::string GetErrorMessage() override
Describes the error (if one occurred during processing).
MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, LiveWireTool2D, "LiveWire tool")
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static Pointer New()
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer image
const char * GetName() const override
Returns the name of this tool. Make it short!
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57