Orfeo Toolbox  3.16
itkImageToCooccurrenceListAdaptor.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageToCooccurrenceListAdaptor.txx,v $
5  Language: C++
6  Date: $Date: 2009-03-04 15:23:50 $
7  Version: $Revision: 1.6 $
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 __itkImageToCooccurrenceListAdaptor_txx
18 #define __itkImageToCooccurrenceListAdaptor_txx
19 
20 namespace itk {
21 namespace Statistics {
22 
23 template < class TImage >
26 {
27  m_Sample = SampleType::New();
28  m_Sample->SetMeasurementVectorSize( MeasurementVectorSize );
29 }
30 
31 template < class TImage >
32 void
34 ::PrintSelf(std::ostream& os, Indent indent) const
35 {
36  Superclass::PrintSelf(os,indent);
37 }
38 
39 template < class TImage >
40 void
43 {
45  radius.Fill(1);
46 
48  // 0 is valid so I chose -1. Is this valid for all images ?
49  boundaryCondition.SetConstant( -1 );
50 
52  ImageType > FaceCalculatorType;
53 
54  FaceCalculatorType faceCalculator;
55  typename FaceCalculatorType::FaceListType faceList;
56  typename FaceCalculatorType::FaceListType::iterator fit;
57 
58  typedef typename ShapedNeighborhoodIteratorType::ConstIterator ShapeNeighborhoodIterator;
59 
60  typedef typename OffsetTable::iterator OffsetIterator;
61 
62  typename SampleType::MeasurementVectorType coords;
63 
64  faceList = faceCalculator( this->GetImage(),
65  this->GetImage()->GetRequestedRegion(),
66  radius );
67 
68  OffsetType center_offset;
69  center_offset.Fill( 0 );
70 
71  for ( fit=faceList.begin(); fit != faceList.end(); ++fit)
72  {
73 
74  ShapedNeighborhoodIteratorType it(radius, this->GetImage(), *fit );
75  it.OverrideBoundaryCondition(&boundaryCondition);
76 
77  OffsetIterator iter = m_OffsetTable.begin();
78  while( iter != m_OffsetTable.end() )
79  {
80  it.ActivateOffset(*iter);
81  iter++;
82  }
83 
84  for ( it.GoToBegin(); !it.IsAtEnd(); ++it )
85  {
86 
87  const PixelType center_pixel_intensity = it.GetPixel( center_offset );
88 
89  ShapeNeighborhoodIterator ci = it.Begin();
90  while ( ci != it.End() )
91  {
92  const PixelType pixel_intensity = ci.Get();
93 
94  // We have the intensity values for the center pixel and one of it's neighbours.
95  // We can now place these in the SampleList
96  coords[0] = center_pixel_intensity;
97  coords[1] = pixel_intensity;
98 
99  m_Sample->PushBack(coords);
100  ci++;
101  }
102  }
103  }
104 
105 }
106 
107 
108 template < class TImage >
109 void
111 ::UseNeighbor(const OffsetType & offset)
112 {
113  // Don't add the center pixel
114  bool isTheCenterPixel = true;
115  for(unsigned int i=0; i<ImageDimension; i++)
116  {
117  if( offset[i] != 0 )
118  {
119  isTheCenterPixel = false;
120  break;
121  }
122  }
123 
124  if( !isTheCenterPixel )
125  {
126  m_OffsetTable.push_back( offset );
127  }
128 }
129 
130 } // end of namespace Statistics
131 } // end of namespace itk
132 
133 #endif

Generated at Sat Feb 2 2013 23:44:57 for Orfeo Toolbox with doxygen 1.8.1.1