Orfeo Toolbox  3.16
itkVectorNeighborhoodOperatorImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkVectorNeighborhoodOperatorImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-17 20:50:03 $
7  Version: $Revision: 1.14 $
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 __itkVectorNeighborhoodOperatorImageFilter_txx
18 #define __itkVectorNeighborhoodOperatorImageFilter_txx
20 
23 #include "itkImageRegionIterator.h"
25 #include "itkProgressReporter.h"
26 
27 namespace itk
28 {
29 
30 template <class TInputImage, class TOutputImage>
31 void
34 {
35  // call the superclass' implementation of this method. this should
36  // copy the output requested region to the input requested region
37  Superclass::GenerateInputRequestedRegion();
38 
39  // get pointers to the input and output
40  InputImagePointer inputPtr =
41  const_cast< InputImageType * >( this->GetInput() );
42 
43  if ( !inputPtr )
44  {
45  return;
46  }
47 
48  // get a copy of the input requested region (should equal the output
49  // requested region)
50  typename TInputImage::RegionType inputRequestedRegion;
51  inputRequestedRegion = inputPtr->GetRequestedRegion();
52 
53  // pad the input requested region by the operator radius
54  inputRequestedRegion.PadByRadius( m_Operator.GetRadius() );
55 
56  // crop the input requested region at the input's largest possible region
57  if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
58  {
59  inputPtr->SetRequestedRegion( inputRequestedRegion );
60  return;
61  }
62  else
63  {
64  // Couldn't crop the region (requested region is outside the largest
65  // possible region). Throw an exception.
66 
67  // store what we tried to request (prior to trying to crop)
68  inputPtr->SetRequestedRegion( inputRequestedRegion );
69 
70  // build an exception
71  InvalidRequestedRegionError e(__FILE__, __LINE__);
72  e.SetLocation(ITK_LOCATION);
73  e.SetDescription("Requested region is (at least partially) outside the largest possible region.");
74  e.SetDataObject(inputPtr);
75  throw e;
76  }
77 }
78 
79 
80 template< class TInputImage, class TOutputImage>
81 void
83 ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
84  int threadId)
85 {
87  BFC;
88  typedef typename BFC::FaceListType FaceListType;
89 
91  BFC faceCalculator;
92  FaceListType faceList;
93 
94  // Allocate output
95  OutputImageType *output = this->GetOutput();
96  const InputImageType *input = this->GetInput();
97 
98  // Break the input into a series of regions. The first region is free
99  // of boundary conditions, the rest with boundary conditions. Note,
100  // we pass in the input image and the OUTPUT requested region. We are
101  // only concerned with centering the neighborhood operator at the
102  // pixels that correspond to output pixels.
103  faceList = faceCalculator(input, outputRegionForThread,
104  m_Operator.GetRadius());
105  typename FaceListType::iterator fit;
106 
107  // support progress methods/callbacks
108  ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
109 
111 
112  // Process non-boundary region and then each of the boundary faces.
113  // These are N-d regions which border the edge of the buffer.
115  for (fit=faceList.begin(); fit != faceList.end(); ++fit)
116  {
117  bit =
118  ConstNeighborhoodIterator<InputImageType>(m_Operator.GetRadius(),
119  input, *fit);
120  it = ImageRegionIterator<OutputImageType>(output, *fit);
121  bit.GoToBegin();
122  while ( ! bit.IsAtEnd() )
123  {
124  it.Value() = smartInnerProduct(bit, m_Operator);
125  ++bit;
126  ++it;
127  progress.CompletedPixel();
128  }
129  }
130 }
131 
132 } // end namespace itk
133 
134 #endif

Generated at Sun Feb 3 2013 00:12:42 for Orfeo Toolbox with doxygen 1.8.1.1