File: itkBinaryMaskToNarrowBandPointSetFilter.h

package info (click to toggle)
insighttoolkit 3.6.0-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 94,956 kB
  • ctags: 74,981
  • sloc: cpp: 355,621; ansic: 195,070; fortran: 28,713; python: 3,802; tcl: 1,996; sh: 1,175; java: 583; makefile: 415; csh: 184; perl: 175
file content (165 lines) | stat: -rw-r--r-- 6,694 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkBinaryMaskToNarrowBandPointSetFilter.h,v $
  Language:  C++
  Date:      $Date: 2004-12-24 22:03:31 $
  Version:   $Revision: 1.5 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkBinaryMaskToNarrowBandPointSetFilter_h
#define __itkBinaryMaskToNarrowBandPointSetFilter_h

#include "itkImageToMeshFilter.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkImageRegionConstIteratorWithIndex.h"
#include "itkReinitializeLevelSetImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"

namespace itk
{

/** \class BinaryMaskToNarrowBandPointSetFilter
 * \brief Generate a PointSet containing the narrow band around the edges of a
 * input binary image.
 *
 * BinaryMaskToNarrowBandPointSetFilter takes a binary image as input
 * and generates a PointSet as output. The point set contains
 * points around the contours of the binary mask in the image.
 * The pixel values of the point set are obtained as the distances
 * from the point to the edge of the binary mask.
 * 
 * This filter is intended to be used for initializing the process
 * of NarrowBand-to-Image Registration.
 *
 * The filter is templated over the input image type and the 
 * output mesh type. The only restriction is that the dimension 
 * of points in the mesh should be equal to the input image dimension.
 * The PixelType in the mesh should be capable to represent distance
 * values.
 * 
 * \sa ReinitializeImageFilter
 * \sa PointSetToImageRegistrationMethod
 * 
 * \ingroup ImageFilters  MeshFilters
 */
template <class TInputImage, class TOutputMesh>
class ITK_EXPORT BinaryMaskToNarrowBandPointSetFilter : 
    public ImageToMeshFilter<TInputImage,TOutputMesh>
{
public:
  /** Standard class typedefs. */
  typedef BinaryMaskToNarrowBandPointSetFilter  Self;
  typedef ProcessObject                Superclass;
  typedef SmartPointer<Self>            Pointer;
  typedef SmartPointer<const Self>      ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);
  
  /** Run-time type information (and related methods). */
  itkTypeMacro(BinaryMaskToNarrowBandPointSetFilter, ImageToMeshFilter);

  /** Some typedefs associated with the input images. */
  typedef TInputImage                               InputImageType;
  typedef typename InputImageType::ConstPointer     InputImageConstPointer;
  typedef typename InputImageType::RegionType       InputImageRegionType; 
  typedef typename InputImageType::PixelType        InputImagePixelType; 
  typedef ImageRegionConstIteratorWithIndex<InputImageType> 
                                                    InputImageIterator;


  /** Some typedefs associated with the output mesh. */
  typedef TOutputMesh OutputMeshType;
  typedef typename OutputMeshType::PointType        PointType;
  typedef typename OutputMeshType::Pointer          OutputMeshPointer;
  typedef typename OutputMeshType::ConstPointer     OutputMeshConstPointer;
  typedef typename OutputMeshType::PointsContainer  PointsContainer; 
  typedef typename OutputMeshType::PointIdentifier  PointIdentifier; 
  typedef typename PointsContainer::Pointer         PointsContainerPointer;
  typedef typename PointsContainer::Iterator        PointsContainerIterator;
  typedef typename OutputMeshType::PointDataContainer PointDataContainer; 
  typedef typename PointDataContainer::Pointer      PointDataContainerPointer;
  typedef typename PointDataContainer::Iterator     PointDataContainerIterator;


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


  /** Float image type to be used by the ReinitializeLevelSet image filter */
  typedef itk::Image< float, 
                itkGetStaticConstMacro(ImageDimension) >   RealImageType;

  /** The ReinitializeLevelSet filter is used to evaluate the distance from
      every pixel to the border of the binary mask. It uses internally a 
      FastMarching filter for propagating a from from the edges of the binary
      mask.  */
  typedef ReinitializeLevelSetImageFilter< RealImageType >
                                                    DistanceFilterType;
 
  typedef typename DistanceFilterType::Pointer                  DistanceFilterPointer; 
  typedef typename DistanceFilterType::NodeContainerPointer     NodeContainerPointer;
  typedef typename DistanceFilterType::NodeContainer            NodeContainer;
  typedef typename NodeContainer::Element                       NodeType;



  /** The ReinitializeLevelSetImageFilter expect the input to be binary
      withing the range [-0.5:0.5]. This filte will scale the input to
      fit in this range. */
  typedef RescaleIntensityImageFilter< InputImageType, RealImageType > RescaleFilterType;

  typedef typename RescaleFilterType::Pointer         RescaleFilterPointer;

  /** The dimension of the output mesh. */
  itkStaticConstMacro(PointDimension, unsigned int,
                      TOutputMesh::PointDimension);

  /** Some typedefs associated with the output mesh. */
  void GenerateData(void);

  /** Some typedefs associated with the output mesh. */
  void GenerateOutputInformation(void);

  /** accept the input image */
  void SetInput( const InputImageType * inputImage );

  /** Set/Get the width of the narrowband. This is the 
      maximum distance from the binary mask edges to
      the points in the narrow band. The full width of 
      the full narrow band will be double of this value. */
  itkSetMacro( BandWidth, float );
  itkGetMacro( BandWidth, float );

protected:
  BinaryMaskToNarrowBandPointSetFilter();
  ~BinaryMaskToNarrowBandPointSetFilter();
  void PrintSelf(std::ostream& os, Indent indent) const;
 
private:
  BinaryMaskToNarrowBandPointSetFilter(const BinaryMaskToNarrowBandPointSetFilter&); //purposely not implemented
  void operator=(const BinaryMaskToNarrowBandPointSetFilter&); //purposely not implemented

  DistanceFilterPointer   m_DistanceFilter;
  RescaleFilterPointer    m_RescaleFilter;

  float                   m_BandWidth;

};

} // end namespace itk

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

#endif