A.I.M.S algorithms


multichannelresampler.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 #ifndef AIMS_RESAMPLING_MULTICHANNELRESAMPLER_H
35 #define AIMS_RESAMPLING_MULTICHANNELRESAMPLER_H
36 
37 
38 #define AIMS_RESAMPLING_DECLARE_MULTICHANNELRESAMPLER( R, T, O ) \
39 template <> \
40 class R< T > : public Resampler< T > \
41 { \
42 public: \
43 \
44  virtual void resample( const AimsData< T >& inVolume, \
45  const Motion& transform3d, \
46  const T& outBackground, \
47  AimsData< T >& outVolume, \
48  bool verbose = false ); \
49 \
50  int getOrder() const { return O; } \
51 \
52 protected: \
53 \
54  virtual void \
55  doResample( const AimsData< T > &, \
56  const Motion &, \
57  const T &, const Point3df &, \
58  T &, int ) {} \
59 \
60 }; \
61 
62 
63 #define AIMS_RESAMPLING_INSTANCIATE_MULTICHANNELRESAMPLER( R, T ) \
64 void \
65 R< T >::resample( const AimsData< T >& inVolume, \
66  const Motion& transform3d, \
67  const T& outBackground, \
68  AimsData< T >& outVolume, \
69  bool verbose ) \
70 { \
71  ChannelSelector< AimsData<T>, AimsData<uint8_t> > selector; \
72  DataTypeInfo< T > info; \
73 \
74  int dimX = outVolume.dimX(); \
75  int dimY = outVolume.dimY(); \
76  int dimZ = outVolume.dimZ(); \
77  int dimT = outVolume.dimT(); \
78  float sizeX = outVolume.sizeX(); \
79  float sizeY = outVolume.sizeY(); \
80  float sizeZ = outVolume.sizeZ(); \
81  float sizeT = outVolume.sizeT(); \
82 \
83  for (uint8_t channel = 0; channel < DataTypeInfo< T >::samples(); channel++) { \
84 \
85  R< uint8_t > resampler; \
86  AimsData<uint8_t> inChannel; \
87  AimsData<uint8_t> outChannel( dimX, dimY, dimZ, dimT ); \
88 \
89  outChannel.setSizeXYZT( sizeX, sizeY, sizeZ, sizeT ); \
90  /* cout << "AimsData<" << DataTypeCode< T >::dataType() << "> -> resampling channel : " << toString(channel) << endl << flush; */ \
91 \
92  if( outVolume.header() ) \
93  { \
94  outChannel.setHeader( outVolume.header()->cloneHeader( true ) ); \
95  } \
96 \
97  /* We split the data and process resampling on each component */ \
98  inChannel = selector.select( inVolume, channel ); \
99 \
100  resampler.setRef( inChannel ); \
101  resampler.setDefaultValue( _defval[ channel ] ); \
102  resampler.resample( inChannel, \
103  transform3d, \
104  outBackground[ channel ], \
105  outChannel, \
106  verbose ); \
107 \
108  selector.set( outVolume, channel, outChannel ); \
109  } \
110 \
111 } \
112 
113 
114 #endif