aimsalgo 6.0.0
Neuroimaging image processing
topoClassifier.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef AIMS_TOPOLOGY_TOPOCLASSIFIER_H
36#define AIMS_TOPOLOGY_TOPOCLASSIFIER_H
37
38#include <cartodata/volume/volume.h>
41#include <aims/bucket/bucketMap.h>
42#include <aims/utility/converter_bucket.h>
43
44
45template< typename T >
47{
48public:
49 class ResultRcType;
50 class ResultType;
51
54
55 ResultRcType doit( const T & );
56 ResultType & takeResult( ResultRcType & d ) { return d; }
57};
58
59
60template< typename T >
61class TopologicalClassifier<carto::VolumeRef<T> >
62{
63public:
66
69
70 ResultRcType doit( const carto::VolumeRef< T >& );
71 ResultType & takeResult( ResultRcType & d ) { return d; }
72};
73
74
75template< typename T >
76class TopologicalClassifier< aims::BucketMap<T> >
77{
78public:
81
84
85 ResultRcType doit( const aims::BucketMap< T >& );
86 ResultType & takeResult( ResultRcType & d ) { return *d; }
87};
88
89
90template< typename T > inline
92 const carto::VolumeRef< T >& d )
93{
94 int x, y, z;
95 T label;
96
97 int dx = d.getSizeX();
98 int dy = d.getSizeY();
99 int dz = d.getSizeZ();
100
102 res.setVoxelSize( d.getVoxelSize() );
103
106
107 for ( z=0; z<dz; z++ )
108 for ( y=0; y<dy; y++ )
109 for ( x=0; x<dx; x++ )
110 if( ( label = d( x, y, z ) ) )
111 {
112 Point3d pt( x, y, z );
113 topo.computeLocalCCNumbers( pt, (int)label );
114 res( x, y, z ) = (short)topoMean.classification( topo.Cstar(),
115 topo.Cbar() );
116 }
117
118 return res;
119}
120
121
122template< typename T > inline
125 const aims::BucketMap< T >& d )
126{
127 typename aims::BucketMap<T>::const_iterator ibm, ebm = d.end();
128 typename aims::BucketMap<T>::Bucket::const_iterator ib, eb;
129
131 res->setSizeXYZT( d.sizeX(), d.sizeY(), d.sizeZ(), d.sizeT() );
132
135 dc = conv( d );
138
139 for( ibm=d.begin(); ibm!=ebm; ++ibm )
140 {
141 aims::BucketMap<int16_t>::Bucket & bk = (*res)[ ibm->first ];
142 for( ib=ibm->second.begin(), eb=ibm->second.end(); ib!=eb; ++ib )
143 {
144 topo.computeLocalCCNumbers( ib->first, ib->second );
145 bk[ ib->first ] = (short)topoMean.classification( topo.Cstar(),
146 topo.Cbar() );
147 }
148 }
149 delete dc;
150
152}
153
154
155template<> inline
158 const aims::BucketMap<Void>& d )
159{
160 aims::BucketMap<Void>::const_iterator ibm, ebm = d.end();
161 aims::BucketMap<Void>::Bucket::const_iterator ib, eb;
162
164 res->setSizeXYZT( d.sizeX(), d.sizeY(), d.sizeZ(), d.sizeT() );
165
168 dc = conv( d );
171
172 for( ibm=d.begin(); ibm!=ebm; ++ibm )
173 {
174 aims::BucketMap<int16_t>::Bucket & bk = (*res)[ ibm->first ];
175 for( ib=ibm->second.begin(), eb=ibm->second.end(); ib!=eb; ++ib )
176 {
177 topo.computeLocalCCNumbers( ib->first, 1 );
178 bk[ ib->first ] = (short)topoMean.classification( topo.Cstar(),
179 topo.Cbar() );
180 }
181 }
182 delete dc;
183
185}
186
187#endif
void computeLocalCCNumbers(const Point3d &, int)
static int classification(int, int)
ResultType & takeResult(ResultRcType &d)
ResultRcType doit(const aims::BucketMap< T > &)
carto::rc_ptr< aims::BucketMap< int16_t > > ResultRcType
ResultRcType doit(const carto::VolumeRef< T > &)
ResultType & takeResult(ResultRcType &d)
virtual ~TopologicalClassifier()
ResultRcType doit(const T &)
float sizeZ() const
std::map< int, Bucket >::const_iterator const_iterator
void setSizeXYZT(float sizex, float sizey, float sizez, float sizet)
std::map< Point3d, T, BucketMapLess > Bucket
float sizeT() const
float sizeY() const
float sizeX() const
int getSizeZ() const
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< float > getVoxelSize() const
std::vector< int > getSize() const
int getSizeY() const
int getSizeX() const
AimsVector< int16_t, 3 > Point3d