Orfeo Toolbox  3.16
itkMRFImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkMRFImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-23 03:53:35 $
7  Version: $Revision: 1.44 $
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 __itkMRFImageFilter_h
18 #define __itkMRFImageFilter_h
19 
20 
21 #include "vnl/vnl_vector.h"
22 #include "vnl/vnl_matrix.h"
23 
24 #include "itkImageClassifierBase.h"
25 
26 #include "itkImageToImageFilter.h"
27 #include "itkImageRegionIterator.h"
28 
32 #include "itkNeighborhood.h"
33 #include "itkSize.h"
34 
35 namespace itk
36 {
37 
128 template <class TInputImage, class TClassifiedImage>
130  public ImageToImageFilter<TInputImage,TClassifiedImage>
131 {
132 public:
139 
141  itkNewMacro(Self);
142 
144  itkTypeMacro(MRFImageFilter,Object);
145 
147  typedef TInputImage InputImageType;
148  typedef typename TInputImage::Pointer InputImagePointer;
149  typedef typename TInputImage::ConstPointer InputImageConstPointer;
150 
152  typedef typename TInputImage::PixelType InputImagePixelType;
153 
155  typedef typename TInputImage::RegionType InputImageRegionType;
156 
160 
162  itkStaticConstMacro(InputImageDimension, unsigned int,
163  TInputImage::ImageDimension);
164 
166  typedef typename TClassifiedImage::Pointer TrainingImagePointer;
167 
169  typedef typename TClassifiedImage::PixelType TrainingImagePixelType;
170 
173  typedef typename TClassifiedImage::Pointer LabelledImagePointer;
174 
177  typedef typename TClassifiedImage::PixelType LabelledImagePixelType;
178 
181  typedef typename TClassifiedImage::RegionType LabelledImageRegionType;
182 
184  typedef typename TClassifiedImage::IndexType LabelledImageIndexType;
185  typedef typename LabelledImageIndexType::IndexValueType IndexValueType;
186 
188  typedef typename TClassifiedImage::OffsetType LabelledImageOffsetType;
189 
193 
195  itkStaticConstMacro(ClassifiedImageDimension, unsigned int,
196  TClassifiedImage::ImageDimension);
197 
200 
202  typedef typename TInputImage::SizeType SizeType;
203 
205  typedef typename TInputImage::SizeType NeighborhoodRadiusType;
206 
210 
213 
216 
219 
220  typedef typename InputImageFaceListType::iterator
222 
226 
229 
232 
235 
236  typedef typename LabelledImageFaceListType::iterator
238 
240  void SetClassifier( typename ClassifierType::Pointer ptrToClassifier );
241 
243  itkSetMacro(NumberOfClasses, unsigned int);
244  itkGetConstMacro(NumberOfClasses, unsigned int);
245 
248  itkSetMacro(MaximumNumberOfIterations, unsigned int);
249  itkGetConstMacro(MaximumNumberOfIterations, unsigned int);
250 
253  itkSetMacro(ErrorTolerance, double);
254  itkGetConstMacro(ErrorTolerance, double);
255 
258  itkSetMacro(SmoothingFactor, double);
259  itkGetConstMacro(SmoothingFactor, double);
260 
262  void SetNeighborhoodRadius(const NeighborhoodRadiusType &);
263 
267  void SetNeighborhoodRadius( const unsigned long );
268  void SetNeighborhoodRadius( const unsigned long *radiusArray );
269 
271  const NeighborhoodRadiusType GetNeighborhoodRadius() const
272  {
273  NeighborhoodRadiusType radius;
274 
275  for(int i=0; i<InputImageDimension; ++i)
276  {
277  radius[i] = m_InputImageNeighborhoodRadius[i];
278  }
279  return radius;
280  }
281 
287  virtual void SetMRFNeighborhoodWeight( std::vector<double> BetaMatrix );
288  virtual std::vector<double> GetMRFNeighborhoodWeight()
289  {
290  return m_MRFNeighborhoodWeight;
291  }
292 
293 //Enum to get the stopping condition of the MRF filter
294  typedef enum{
295  MaximumNumberOfIterations=1,
296  ErrorTolerance
297  } StopConditionType;
298 
301  itkGetConstReferenceMacro( StopCondition, StopConditionType );
302 
303  /* Get macro for number of iterations */
304  itkGetConstReferenceMacro( NumberOfIterations, unsigned int );
305 
306 #ifdef ITK_USE_CONCEPT_CHECKING
307 
308  itkConceptMacro(UnsignedIntConvertibleToClassifiedCheck,
310  itkConceptMacro(ClassifiedConvertibleToUnsignedIntCheck,
312  itkConceptMacro(ClassifiedConvertibleToIntCheck,
314  itkConceptMacro(IntConvertibleToClassifiedCheck,
316  itkConceptMacro(SameDimensionCheck,
319 #endif
320 
321 protected:
322  MRFImageFilter();
323  ~MRFImageFilter();
324  void PrintSelf(std::ostream& os, Indent indent) const;
325 
327  void Allocate();
328 
333  virtual void ApplyMRFImageFilter();
334 
336  virtual void MinimizeFunctional();
337 
343 
347  //Function implementing the neighborhood operation
348 
349  virtual void DoNeighborhoodOperation( const InputImageNeighborhoodIterator &imageIter,
350  LabelledImageNeighborhoodIterator &labelledIter,
351  LabelStatusImageNeighborhoodIterator &labelStatusIter );
352 
353  virtual void GenerateData();
354  virtual void GenerateInputRequestedRegion();
355  virtual void EnlargeOutputRequestedRegion( DataObject * );
356  virtual void GenerateOutputInformation();
357 
358 private:
359  MRFImageFilter(const Self&); //purposely not implemented
360  void operator=(const Self&); //purposely not implemented
361 
362  typedef typename TInputImage::SizeType InputImageSizeType;
363 
366 
369 
372 
373  typedef typename LabelStatusImageFaceListType::iterator
375 
379 
380  unsigned int m_NumberOfClasses;
382  unsigned int m_KernelSize;
383 
390  double *m_ClassProbability; //Class liklihood
391  unsigned int m_NumberOfIterations;
393 
395 
396  std::vector<double> m_MRFNeighborhoodWeight;
397  std::vector<double> m_NeighborInfluence;
398  std::vector<double> m_MahalanobisDistance;
399  std::vector<double> m_DummyVector;
400 
403 
404 
408  virtual void SetDefaultMRFNeighborhoodWeight( );
409 
410  //Function implementing the ICM algorithm to label the images
411  void ApplyICMLabeller();
412 
413 }; // class MRFImageFilter
414 
415 
416 } // namespace itk
417 
418 #ifndef ITK_MANUAL_INSTANTIATION
419 #include "itkMRFImageFilter.txx"
420 #endif
421 
422 #endif

Generated at Sat Jun 15 2013 23:54:45 for Orfeo Toolbox with doxygen 1.8.3.1