MCPcopy Create free account
hub / github.com/MITK/MITK / GenerateOutputInformation

Method GenerateOutputInformation

Modules/AlgorithmsExt/src/mitkAutoCropImageFilter.cpp:71–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void mitk::AutoCropImageFilter::GenerateOutputInformation()
72{
73 mitk::Image::Pointer input = const_cast<mitk::Image *>(this->GetInput());
74 mitk::Image::Pointer output = this->GetOutput();
75
76 if (input->GetDimension() <= 2)
77 {
78 MITK_ERROR << "Only 3D any 4D images are supported." << std::endl;
79 return;
80 }
81
82 ComputeNewImageBounds();
83
84 if ((output->IsInitialized()) && (output->GetPipelineMTime() <= m_TimeOfHeaderInitialization.GetMTime()))
85 return;
86
87 itkDebugMacro(<< "GenerateOutputInformation()");
88
89 // PART I: initialize input requested region. We do this already here (and not
90 // later when GenerateInputRequestedRegion() is called), because we
91 // also need the information to setup the output.
92
93 // pre-initialize input-requested-region to largest-possible-region
94 // and correct time-region; spatial part will be cropped by
95 // bounding-box of bounding-object below
96 m_InputRequestedRegion = input->GetLargestPossibleRegion();
97
98 // build region out of index and size calculated in ComputeNewImageBounds()
99
100 mitk::SlicedData::IndexType index;
101 index[0] = m_RegionIndex[0];
102 index[1] = m_RegionIndex[1];
103 index[2] = m_RegionIndex[2];
104 index[3] = m_InputRequestedRegion.GetIndex()[3];
105 index[4] = m_InputRequestedRegion.GetIndex()[4];
106
107 mitk::SlicedData::SizeType size;
108 size[0] = m_RegionSize[0];
109 size[1] = m_RegionSize[1];
110 size[2] = m_RegionSize[2];
111 size[3] = m_InputRequestedRegion.GetSize()[3];
112 size[4] = m_InputRequestedRegion.GetSize()[4];
113
114 mitk::SlicedData::RegionType cropRegion(index, size);
115
116 // crop input-requested-region with cropping region computed from the image data
117 if (m_InputRequestedRegion.Crop(cropRegion) == false)
118 {
119 // crop not possible => do nothing: set time size to 0.
120 size.Fill(0);
121 m_InputRequestedRegion.SetSize(size);
122 return;
123 }
124
125 // set input-requested-region, because we access it later in
126 // GenerateInputRequestedRegion (there we just set the time)
127 input->SetRequestedRegion(&m_InputRequestedRegion);
128

Callers

nothing calls this directly

Calls 15

PixelTypeClass · 0.85
GetDimensionsMethod · 0.80
GetGeometryMethod · 0.80
GetPointerMethod · 0.80
GetSlicedGeometryMethod · 0.80
GetAxisVectorMethod · 0.80
NewFunction · 0.50
GetInputMethod · 0.45
GetOutputMethod · 0.45
GetDimensionMethod · 0.45

Tested by

no test coverage detected