Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageChannelSelector.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 
18 
20 {
21 }
22 
24 {
25 }
26 
28 {
29  mitk::Image::ConstPointer input = this->GetInput();
30  mitk::Image::Pointer output = this->GetOutput();
31 
32  itkDebugMacro(<< "GenerateOutputInformation()");
33 
34  output->Initialize(input->GetPixelType(), input->GetDimension(), input->GetDimensions());
35 
36  // initialize geometry
37  output->SetPropertyList(input->GetPropertyList()->Clone());
38  mitk::TimeGeometry::Pointer clonGeometry = input->GetTimeGeometry()->Clone();
39  output->SetTimeGeometry(clonGeometry.GetPointer());
40 }
41 
43 {
44  const Image::RegionType &requestedRegion = GetOutput()->GetRequestedRegion();
45 
46  // do we really need the complete channel?
47  if (requestedRegion.GetSize(3) > 1)
48  SetChannelItem(GetChannelData(m_ChannelNr), 0);
49  else
50  // or only a complete volume at a time?
51  if (requestedRegion.GetSize(2) > 1)
52  SetVolumeItem(GetVolumeData(requestedRegion.GetIndex(3), m_ChannelNr), requestedRegion.GetIndex(3), 0);
53  else
54  // not even a complete volume, so now take just a slice!
55  SetSliceItem(GetSliceData(requestedRegion.GetIndex(2), requestedRegion.GetIndex(3), m_ChannelNr),
56  requestedRegion.GetIndex(2),
57  requestedRegion.GetIndex(3),
58  0);
59 }
60 
62 {
63  Superclass::GenerateInputRequestedRegion();
64 
66  const_cast<mitk::ImageToImageFilter::InputImageType *>(this->GetInput());
67  mitk::Image::Pointer output = this->GetOutput();
68 
69  Image::RegionType requestedRegion;
70  requestedRegion = output->GetRequestedRegion();
71  requestedRegion.SetIndex(4, m_ChannelNr);
72  requestedRegion.SetSize(4, 1);
73 
74  input->SetRequestedRegion(&requestedRegion);
75 }
virtual void GenerateInputRequestedRegion() override
itk::ImageRegion< RegionDimension > RegionType
Image class for storing images.
Definition: mitkImage.h:76
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
virtual void GenerateOutputInformation() override