aimsdata 6.0.0
Neuroimaging data handling
minmax.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_UTILITY_MINMAX_H
35#define AIMS_UTILITY_MINMAX_H
36
37#include <cartodata/volume/volume.h>
38
39namespace aims
40{
41
42 //-----------------------------------//
43 // minmax< ObjectType, ValueType > //
44//-----------------------------------//
45template <typename ObjectType, typename ValueType>
46void minmax( const ObjectType &, ValueType &min, ValueType &max );
47
48//-----------------------------------------------------------------------------
49template <typename ObjectType, typename ValueType>
50void minmax( const ObjectType &, ValueType &min, ValueType &max )
51{
52 ObjectType::error_minmax_not_specialized;
53}
54
55
56 //-------------------------------------------------//
57 // minmax< carto::Volume<ValueType>, ValueType > //
58//-------------------------------------------------//
59template <typename ValueType>
60void minmax( const carto::Volume<ValueType> &volume, ValueType &min,
61 ValueType &max )
62{
63 const ValueType *it;
64 int dx = volume.getSizeX();
65 int dy = volume.getSizeY();
66 int dz = volume.getSizeZ();
67 int dt = volume.getSizeT();
68
69 min = max = volume.at( 0 );
70 for ( int t = 0; t < dt; t++ )
71 {
72 for ( int z = 0; z < dz; z++ )
73 {
74 for ( int y = 0; y < dy; y++ )
75 {
76 it = &volume.at( 0, y, z, t );
77 for ( int x = 0; x < dx; x++ )
78 {
79 if ( *it < min ) min = *it;
80 if ( *it > max ) max = *it;
81 it++;
82 }
83 }
84 }
85 }
86}
87
88
89 //-----------------------------------------------------------------//
90 // minmax< carto::rc_prr<carto::Volume<ValueType> >, ValueType > //
91//-----------------------------------------------------------------//
92template <typename ValueType>
94 ValueType &min, ValueType &max )
95{
96 minmax( *volume, min, max );
97}
98
99
100 //----------------------------------------------------//
101 // minmax< carto::VolumeRef<ValueType>, ValueType > //
102//----------------------------------------------------//
103template <typename ValueType>
105 ValueType &min, ValueType &max )
106{
107 minmax( *volume, min, max );
108}
109
110
111} // namespace aims
112
113#endif // ifndef AIMS_UTILITY_MINMAX_H
int getSizeY() const
int getSizeX() const
int getSizeZ() const
int getSizeT() const
const T & at(long x, long y=0, long z=0, long t=0) const
The class for EcatSino data write operation.
void minmax(const ObjectType &, ValueType &min, ValueType &max)
Definition minmax.h:50
T min(const Volume< T > &vol)
T max(const Volume< T > &vol)