KWStyle - itkSparseImage.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkSparseImage.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
7   Version:   $Revision: 1.4 $
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 DEF #ifndef __itkSparseImage_h_
18 DEF #define __itkSparseImage_h_
19
20 #include "itkImage.h"
21 #include "itkSparseFieldLayer.h"
22 #include "itkObjectStore.h"
23
24 namespace itk {
25  
26 /**
27  * \class SparseImage
28  *
29  * \brief This class implements a storage type for sparse image data.
30  *
31  * \par
32  * This class is derived from the Image class. It uses the base class image
33  * data for storing pointers to variables of type TNode. The node type must
34  * have a member variable m_Index. The node data is
35  * stored using the SparseFieldLayer and ObjectStore classes to allow
36  * sequential list access to the nodes. This functionality is used in filter
37  * classes that process the SparseImage class such as
38  * FiniteDifferenceSparseImageFilter.
39  *
40  * \par
41  * This class provides the method AddNode which allocates a node variable,
42  * associates it with the image pixel index (sets m_Index in the node variable)
43  * and returns the pointer to the node variable. It is suggested that the user
44  * call the FillBuffer method to initialize the image to null pointers before
45  * any calls to AddNode. This would allow the user later to distinguish between
46  * valid and non-valid pixels.
47  *
48  */
49
50 template <class TNode, unsigned int VImageDimension=2>
51 class ITK_EXPORT SparseImage : public Image <TNode*, VImageDimension>
52 {
53 IND **public:
54   /** Standard typedefs. */
55   typedef SparseImage Self;
56 TDA   typedef Image <TNode*, VImageDimension> Superclass;
57 TDA   typedef SmartPointer<Self>  Pointer;
58 TDA   typedef SmartPointer<const Self> ConstPointer;
59 TDA   typedef WeakPointer<const Self> ConstWeakPointer;
60   
61   /** Method for creation through the object factory. */
62   itkNewMacro(Self);
63
64   /** Run-time type information (and related methods). */
65   itkTypeMacro(SparseImage, Image);
66
67   /** Dimension of the image. */
68   itkStaticConstMacro(ImageDimension, unsigned int,
69                       Superclass::ImageDimension);
70
71   /** The actual sparse pixel type. */
72   typedef TNode NodeType;
73
74   /** Types derived from the Superclass */
75   typedef typename Superclass::IndexType IndexType;
76
77   /** Tyepdef for the functor used to access a neighborhood of pixel pointers.*/
78   typedef NeighborhoodAccessorFunctor< Self > 
79 IND ********************************************NeighborhoodAccessorFunctorType;
80
81   typedef typename Superclass::IOPixelType  IOPixelType;
82
83   /** The list types for storing the active pixels.*/
84   typedef SparseFieldLayer <NodeType> NodeListType;
85   typedef ObjectStore      <NodeType> NodeStoreType;
86
87   /** Return the NeighborhoodAccessor functor. This method is called by the 
88    * neighborhood iterators. */
89   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() 
90     { return NeighborhoodAccessorFunctorType(); }
91   
92   /** Return the NeighborhoodAccessor functor. This method is called by the 
93    * neighborhood iterators. */
94   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
95     { return NeighborhoodAccessorFunctorType(); }
96   
97   /** This function should be used to allocate memory for a variable at the
98 IND ******desired pixel location. */
99   NodeType *AddNode(const IndexType &index)
100 IND **{
101     m_NodeList->PushFront(m_NodeStore->Borrow());
102     NodeType *node = m_NodeList->Front();
103     node->m_Index=index;
104     this->SetPixel(index,node);
105     return node;
106 IND **}
107
108   /** This function returns the allocated node list which can be used to
109 IND ******iterate through the valid nodes. */
110   NodeListType* GetNodeList() 
111 IND **{
112 IND ***return m_NodeList;
113 IND **}
114
115   /** This function initializes the m_NodeList and m_NodeStore variables, and
116 IND ******calls the superclass Initialize method. */
117   virtual void Initialize();
118   
119 protected:
120   SparseImage();
121   ~SparseImage() {};
122   
123   void PrintSelf(std::ostream& os, Indent indent) const;
124   
125 private:
126   /** The variables for storing the node variables. */
127   typename NodeListType::Pointer     m_NodeList;
128   typename NodeStoreType::Pointer    m_NodeStore;
129   
130   SparseImage(const Self&); //purposely not implemented
131   void operator=(const Self&); //purposely not implemented
132 };
133
134 }// end namespace itk
135
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "itkSparseImage.txx"
138 #endif
139
140 #endif
141

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:47PM
© Kitware Inc.