Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageSliceSelector.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 "mitkImageSliceSelector.h"
18 
20 {
21  mitk::Image::ConstPointer input = this->GetInput();
22  mitk::Image::Pointer output = this->GetOutput();
23 
24  itkDebugMacro(<< "GenerateOutputInformation()");
25 
26  output->Initialize(input->GetPixelType(), 2, input->GetDimensions());
27 
28  if ((unsigned int)m_SliceNr >= input->GetDimension(2))
29  {
30  m_SliceNr = input->GetDimension(2) - 1;
31  }
32 
33  if ((unsigned int)m_TimeNr >= input->GetDimension(3))
34  {
35  m_TimeNr = input->GetDimension(3) - 1;
36  }
37 
38  // initialize geometry
39  output->SetGeometry(dynamic_cast<BaseGeometry *>(
40  input->GetSlicedGeometry(m_TimeNr)->GetPlaneGeometry(m_SliceNr)->Clone().GetPointer()));
41  output->SetPropertyList(input->GetPropertyList()->Clone());
42 }
43 
45 {
46  SetSliceItem(GetSliceData(m_SliceNr, m_TimeNr, m_ChannelNr), 0);
47 }
48 
49 mitk::ImageSliceSelector::ImageSliceSelector() : m_SliceNr(0), m_TimeNr(0), m_ChannelNr(0)
50 {
51 }
52 
54 {
55 }
56 
58 {
59  Superclass::GenerateInputRequestedRegion();
60 
62  const_cast<mitk::ImageToImageFilter::InputImageType *>(this->GetInput());
63  mitk::Image::Pointer output = this->GetOutput();
64 
65  Image::RegionType requestedRegion;
66  requestedRegion = output->GetRequestedRegion();
67  requestedRegion.SetIndex(2, m_SliceNr);
68  requestedRegion.SetIndex(3, m_TimeNr);
69  requestedRegion.SetIndex(4, m_ChannelNr);
70  requestedRegion.SetSize(2, 1);
71  requestedRegion.SetSize(3, 1);
72  requestedRegion.SetSize(4, 1);
73 
74  input->SetRequestedRegion(&requestedRegion);
75 }
virtual void GenerateInputRequestedRegion() override
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
itk::ImageRegion< RegionDimension > RegionType
Image class for storing images.
Definition: mitkImage.h:76
InputImageType * GetInput(void)
OutputType * GetOutput()
Get the output data of this image source object.
virtual void GenerateOutputInformation() override