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
mitkMaskAndCutRoiImageFilter.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 ===================================================================*/
17 
19 #include "mitkImageCast.h"
20 
22 {
23  this->SetNumberOfRequiredInputs(2);
27 }
28 
30 {
31 }
32 
34 {
35  mitk::Image::Pointer image = dynamic_cast<mitk::Image *>(roi);
36 
37  if (image.IsNotNull())
38  {
39  this->SetInput(1, image);
40  return;
41  }
42 
43  mitk::BoundingObject::Pointer boundingObject = dynamic_cast<mitk::BoundingObject *>(roi);
44  if (boundingObject.IsNotNull() && this->GetInput(0) != nullptr)
45  {
47  filter->SetBoundingObject(boundingObject);
48  filter->SetInput(this->GetInput(0));
49  filter->Update();
50 
51  this->SetInput(1, filter->GetOutput());
52  return;
53  }
54 }
55 
57 {
58  return m_outputImage;
59 }
60 
62 {
63  mitk::Image::ConstPointer inputImage = this->GetInput(0);
64  mitk::Image::ConstPointer maskImage = this->GetInput(1);
65  // mitk::Image::Pointer outputImage = this->GetOutput();
66  // temporary fix for bug #
67  m_outputImage = this->GetOutput();
68 
71 
72  m_CropFilter->SetInput(maskImage);
73  m_CropFilter->SetBackgroundValue(0);
74  m_CropFilter->Update();
75 
76  RegionType region = m_CropFilter->GetCroppingRegion();
77 
78  mitk::CastToItkImage(inputImage, itkImage);
79  m_RoiFilter->SetInput(itkImage);
80  m_RoiFilter->SetRegionOfInterest(region);
81  m_RoiFilter->Update();
82 
83  mitk::CastToMitkImage(m_RoiFilter->GetOutput(), tmpImage);
84 
85  m_MaskFilter->SetInput(0, tmpImage);
86  m_MaskFilter->SetMask(m_CropFilter->GetOutput());
87 
88  m_MaskFilter->SetOutsideValue(-32765);
89  m_MaskFilter->Update();
90  m_MaxValue = m_MaskFilter->GetMaxValue();
91  m_MinValue = m_MaskFilter->GetMinValue();
92 
93  // temporary fix for bug #
94  m_outputImage = m_MaskFilter->GetOutput();
95  m_outputImage->DisconnectPipeline();
96 }
mitk::AutoCropImageFilter::Pointer m_CropFilter
itk::SmartPointer< Self > Pointer
Base of all data objects.
Definition: mitkBaseData.h:39
static Pointer New()
superclass of all bounding objects (cylinder, cuboid,...)
static Pointer New()
mitk::MaskImageFilter::Pointer m_MaskFilter
Image class for storing images.
Definition: mitkImage.h:76
void GenerateData() override
A version of GenerateData() specific for image processing filters.
static Pointer New()
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
Definition: mitkImageCast.h:78
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 itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.