File: RandomForestClassifyImageFilter.h

package info (click to toggle)
itksnap 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,196 kB
  • ctags: 9,196
  • sloc: cpp: 62,895; sh: 175; makefile: 13
file content (83 lines) | stat: -rw-r--r-- 2,905 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef RANDOMFORESTCLASSIFYIMAGEFILTER_H
#define RANDOMFORESTCLASSIFYIMAGEFILTER_H

#include "itkImageToImageFilter.h"

class RandomForestClassifier;

/**
 * @brief A class that takes multiple multi-component images and uses a
 * Gaussian mixture model to combine them into a single probability map.
 *
 * // TODO: derive this and the GMM filter from a common base class that
 * // simplifies working with multiple vector/scalar images
 */
template <class TInputImage, class TInputVectorImage, class TOutputImage>
class RandomForestClassifyImageFilter :
    public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:

  /** Pixel Type of the input image */
  typedef TInputImage                                    InputImageType;
  typedef typename InputImageType::PixelType             InputPixelType;
  typedef typename InputImageType::InternalPixelType InputComponentType;
  typedef typename InputImageType::RegionType      InputImageRegionType;

  /** Define the corresponding vector image */
  typedef TInputVectorImage                        InputVectorImageType;

  /** Pixel Type of the output image */
  typedef TOutputImage                                  OutputImageType;
  typedef typename OutputImageType::PixelType           OutputPixelType;
  typedef typename OutputImageType::RegionType    OutputImageRegionType;
  typedef typename OutputImageType::Pointer          OutputImagePointer;

  /** Standard class typedefs. */
  typedef RandomForestClassifyImageFilter                          Self;
  typedef itk::ImageSource<OutputImageType>                  Superclass;
  typedef itk::SmartPointer<Self>                               Pointer;
  typedef itk::SmartPointer<const Self>                    ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self)

  /** Image dimension. */
  itkStaticConstMacro(ImageDimension, unsigned int,
                      TInputImage::ImageDimension);

  /** Add a scalar input image */
  void AddScalarImage(InputImageType *image);

  /** Add a vector (multi-component) input image */
  void AddVectorImage(InputVectorImageType *image);

  /** Set the mixture model */
  void SetClassifier(RandomForestClassifier *classifier);

  /** Get the current classifier */
  irisGetMacro(Classifier, RandomForestClassifier *);

  /** We need to override this method because of multiple input types */
  void GenerateInputRequestedRegion();

protected:

  RandomForestClassifyImageFilter();
  virtual ~RandomForestClassifyImageFilter();

  void PrintSelf(std::ostream& os, itk::Indent indent) const;

  void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread,
                            itk::ThreadIdType threadId);

  RandomForestClassifier *m_Classifier;
};

#ifndef ITK_MANUAL_INSTANTIATION
#include "RandomForestClassifyImageFilter.txx"
#endif



#endif // RANDOMFORESTCLASSIFYIMAGEFILTER_H