A.I.M.S algorithms


ggradient.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 
36 #ifndef AIMS_SIGNALFILTER_GGRADIENT_H
37 #define AIMS_SIGNALFILTER_GGRADIENT_H
38 
43 
44 
45 template< class T >
47 {
48 public:
49 
50  GaussianGradient( float sx=1.0f, float sy=1.0f, float sz=1.0f );
51  virtual ~GaussianGradient() { }
52 
55 private:
56 
57  float sigx;
58  float sigy;
59  float sigz;
60 };
61 
62 
63 template< class T > inline
64 GaussianGradient< T >::GaussianGradient( float sx, float sy, float sz )
65  : sigx( sx ), sigy( sy ), sigz( sz )
66 {
67  ASSERT( sigx >= 0.1f && sigx <= 100.0f );
68  ASSERT( sigy >= 0.1f && sigy <= 100.0f );
69  ASSERT( sigz >= 0.1f && sigz <= 100.0f );
70 }
71 
72 
73 template< class T > inline AimsData< float >
75 {
76  int x,y,z;
77  float sx = sigx / data.sizeX();
78  float sy = sigy / data.sizeY();
79  float sz = sigz / data.sizeZ();
80 
83 
84  AimsData< float> imaF;
85  imaF=AimsData<float>( data.dimX(), data.dimY(), data.dimZ(),
86  data.dimT() );
87  conv.convert( data, imaF );
88 
89  for ( int i=0; i<3; i++ )
90  res[i]=imaF.clone();
91 
92 
93 
94  AimsData<float> grad;
95  grad=AimsData<float>( data.dimX(), data.dimY(), data.dimZ(), data.dimT() );
96 
97  GaussianSlices gsli;
98  GaussianLines glin;
99  GaussianColumns gcol;
100 
101  // d / dx
102  glin.doit( res[ 0 ], GCoef( sx, GCoef::gradient ) );
103  gcol.doit( res[ 0 ], GCoef( sy ) ); // because default is smoothing
104  gsli.doit( res[ 0 ], GCoef( sz ) );
105 
106  // d / dy
107  glin.doit( res[ 1 ], GCoef( sx ) );
108  gcol.doit( res[ 1 ], GCoef( sy, GCoef::gradient ) );
109  gsli.doit( res[ 1 ], GCoef( sz ) );
110 
111  // d / dz
112  glin.doit( res[ 2 ], GCoef( sx ) );
113  gcol.doit( res[ 2 ], GCoef( sy ) );
114  gsli.doit( res[ 2 ], GCoef( sz, GCoef::gradient ) );
115 
116  for (z=0; z< data.dimZ(); z++)
117  for (y=0; y< data.dimY(); y++)
118  for(x=0; x< data.dimX(); x++)
119  {
120  grad(x,y,z)=sqrt ( (res[0](x,y,z)*res[0](x,y,z))
121  + (res[1](x,y,z)*res[1](x,y,z))
122  + (res[2](x,y,z)*res[2](x,y,z)) );
123  }
124 
125  return grad;
126 }
127 
128 template< class T > inline AimsVector< AimsData< float >, 3 >
130 {
131  float sx = sigx / data.sizeX();
132  float sy = sigy / data.sizeY();
133  float sz = sigz / data.sizeZ();
134 
137 
138  AimsData< float> imaF;
139  imaF=AimsData<float>( data.dimX(), data.dimY(), data.dimZ(),
140  data.dimT() );
141  conv.convert( data, imaF );
142 
143  for ( int i=0; i<3; i++ )
144  res[i]=imaF.clone();
145 
146 
147 
148  AimsData<float> grad;
149  grad=AimsData<float>( data.dimX(), data.dimY(), data.dimZ(), data.dimT() );
150 
151  GaussianSlices gsli;
152  GaussianLines glin;
153  GaussianColumns gcol;
154 
155  // d / dx
156  glin.doit( res[ 0 ], GCoef( sx, GCoef::gradient ) );
157  gcol.doit( res[ 0 ], GCoef( sy ) ); // because default is smoothing
158  gsli.doit( res[ 0 ], GCoef( sz ) );
159 
160  // d / dy
161  glin.doit( res[ 1 ], GCoef( sx ) );
162  gcol.doit( res[ 1 ], GCoef( sy, GCoef::gradient ) );
163  gsli.doit( res[ 1 ], GCoef( sz ) );
164 
165  // d / dz
166  glin.doit( res[ 2 ], GCoef( sx ) );
167  gcol.doit( res[ 2 ], GCoef( sy ) );
168  gsli.doit( res[ 2 ], GCoef( sz, GCoef::gradient ) );
169 
170  return res ;
171 }
172 #endif
AimsVector< AimsData< float >, 3 > doitGradientVector(const AimsData< T > &data)
Definition: ggradient.h:129
void doit(AimsData< float > &)
GaussianGradient(float sx=1.0f, float sy=1.0f, float sz=1.0f)
Definition: ggradient.h:64
virtual ~GaussianGradient()
Definition: ggradient.h:51
int dimX() const
float sizeY() const
int dimT() const
Definition: gcoef.h:41
AimsData< T > clone() const
void doit(AimsData< float > &)
virtual void convert(const INP &in, OUTP &out) const
float sizeZ() const
float sizeX() const
int dimZ() const
int dimY() const
#define ASSERT(EX)
AimsData< float > doit(const AimsData< T > &)
Definition: ggradient.h:74