Orfeo Toolbox  3.16
itkWatershedEquivalenceRelabeler.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkWatershedEquivalenceRelabeler.txx,v $
5  Language: C++
6  Date: $Date: 2009-01-27 19:30:18 $
7  Version: $Revision: 1.9 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkWatershedEquivalenceRelabeler_txx
18 #define __itkWatershedEquivalenceRelabeler_txx
21 #include "itkImageRegionIterator.h"
22 namespace itk
23 {
24 namespace watershed
25 {
26 template <class TScalarType, unsigned int TImageDimension>
29 {
30  typename ImageType::ConstPointer input = this->GetInputImage();
31  typename ImageType::Pointer output = this->GetOutputImage();
32 
33  typename EquivalencyTableType::Pointer eqT = this->GetEquivalencyTable();
34 
35  output->SetBufferedRegion(output->GetRequestedRegion());
36  output->Allocate();
37 
38  //
39  // Copy input to output
40  //
41  ImageRegionConstIterator<ImageType> it_a(input, output->GetRequestedRegion());
42  ImageRegionIterator<ImageType> it_b(output, output->GetRequestedRegion());
43 
44  it_a = it_a.Begin();
45  it_b = it_b.Begin();
46  while (! it_a.IsAtEnd() )
47  {
48  it_b.Set(it_a.Get());
49  ++it_a;
50  ++it_b;
51  }
52 
53  eqT->Flatten();
54  SegmenterType::RelabelImage(output, output->GetRequestedRegion(), eqT);
55 }
56 
57 template <class TScalarType, unsigned int VImageDimension>
60 {
61  // call the superclass' implementation of this method
62  Superclass::GenerateInputRequestedRegion();
63 
64  // get pointers to the input and output
65  ImageType *inputPtr = const_cast<ImageType *> (this->GetInputImage());
66  ImageType *outputPtr = this->GetOutputImage();
67 
68  if ( !inputPtr || !outputPtr )
69  {
70  return;
71  }
72 
73  //
74  // FOR NOW WE'LL JUST SET THE INPUT REGION TO THE OUTPUT REGION
75  // FOR STREAMING WITHIN THE PIPELINE NEED TO FIX THIS
76  //
77  inputPtr->SetRequestedRegion( outputPtr->GetRequestedRegion() );
78 }
79 
80 template <class TScalarType, unsigned int TImageDimension>
83 {
84  // Only the Image output need to be propagated through.
85  // No choice but to use RTTI here.
86  // All Image outputs set to the same RequestedRegion other
87  // outputs ignored.
90  imgData = dynamic_cast<ImageBase<ImageDimension> * >(output);
91 
92  if (imgData)
93  {
94  std::vector<ProcessObject::DataObjectPointer>::size_type idx;
95  for (idx = 0; idx < this->GetOutputs().size(); ++idx)
96  {
97  if (this->GetOutputs()[idx] && this->GetOutputs()[idx] != output)
98  {
99  op = dynamic_cast<ImageBase<ImageDimension> *>(this->GetOutputs()[idx].GetPointer());
100  if (op) this->GetOutputs()[idx]->SetRequestedRegion(output);
101  }
102  }
103  }
104 }
105 
106 template <class TScalarType, unsigned int TImageDimension>
108 ::PrintSelf(std::ostream& os, Indent indent) const
109 {
110  Superclass::PrintSelf(os,indent);
111 }
112 
113 template <class TScalarType, unsigned int TImageDimension>
116 ::MakeOutput(unsigned int )
117 {
118  return static_cast<DataObject*>(ImageType::New().GetPointer());
119 }
120 
121 
122 
123 }// end namespace watershed
124 }// end namespace itk
125 
126 #endif

Generated at Sun May 19 2013 00:15:03 for Orfeo Toolbox with doxygen 1.8.3.1