Medical Imaging Interaction Toolkit  2018.4.99-dcb22cd7
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 (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 
14 
16 {
17 }
18 
20 {
21 }
22 
24 {
25  mitk::Image::ConstPointer input = this->GetInput();
26  mitk::Image::Pointer output = this->GetOutput();
27 
28  itkDebugMacro(<< "GenerateOutputInformation()");
29 
30  output->Initialize(input->GetPixelType(), input->GetDimension(), input->GetDimensions());
31 
32  // initialize geometry
33  output->SetPropertyList(input->GetPropertyList()->Clone());
34  mitk::TimeGeometry::Pointer clonGeometry = input->GetTimeGeometry()->Clone();
35  output->SetTimeGeometry(clonGeometry.GetPointer());
36 }
37 
39 {
40  const Image::RegionType &requestedRegion = GetOutput()->GetRequestedRegion();
41 
42  // do we really need the complete channel?
43  if (requestedRegion.GetSize(3) > 1)
45  else
46  // or only a complete volume at a time?
47  if (requestedRegion.GetSize(2) > 1)
48  SetVolumeItem(GetVolumeData(requestedRegion.GetIndex(3), m_ChannelNr), requestedRegion.GetIndex(3), 0);
49  else
50  // not even a complete volume, so now take just a slice!
51  SetSliceItem(GetSliceData(requestedRegion.GetIndex(2), requestedRegion.GetIndex(3), m_ChannelNr),
52  requestedRegion.GetIndex(2),
53  requestedRegion.GetIndex(3),
54  0);
55 }
56 
58 {
60 
62  mitk::Image::Pointer output = this->GetOutput();
63 
64  Image::RegionType requestedRegion;
65  requestedRegion = output->GetRequestedRegion();
66  requestedRegion.SetIndex(4, m_ChannelNr);
67  requestedRegion.SetSize(4, 1);
68 
69  input->SetRequestedRegion(&requestedRegion);
70 }
mitk::Image::ImageDataItemPointer GetVolumeData(int t=0, int n=0)
mitk::Image::ImageDataItemPointer GetSliceData(int s=0, int t=0, int n=0)
void SetSliceItem(mitk::Image::ImageDataItemPointer dataItem, int s=0, int t=0, int n=0)
itk::ImageRegion< RegionDimension > RegionType
void SetVolumeItem(mitk::Image::ImageDataItemPointer dataItem, int t=0, int n=0)
InputImageType * GetInput(void)
void SetChannelItem(mitk::Image::ImageDataItemPointer dataItem, int n=0)
OutputType * GetOutput()
Get the output data of this image source object.
void GenerateInputRequestedRegion() override
mitk::Image::ImageDataItemPointer GetChannelData(int n=0)