33 #ifndef AIMSALGO_REGISTRATION_PREPROCESSING_D_H
34 #define AIMSALGO_REGISTRATION_PREPROCESSING_D_H
64 const T &
min,
const T &
max,
69 for(
long t = 0; t < in.
getSizeT(); ++t )
70 for(
long z = 0; z < in.
getSizeZ(); ++z )
71 for(
long y = 0; y < in.
getSizeY(); ++y )
72 for(
long x = 0; x < in.
getSizeX(); ++x )
74 T val = tmp(x, y, z, t);
76 tmp(x, y, z, t) =
min;
78 tmp(x, y, z, t) =
max;
85 const T &
min,
const T &
max )
100 return clipDynamic( out, flatten_mask, pct_kept,
true );
103 template <
typename T>
120 T trueMin = *std::min_element( vol.
begin(), vol.
end() );
121 for(
int z = 0; z < vol.
getSizeZ(); ++z )
122 for(
int y = 0; y < vol.
getSizeY(); ++y )
123 for(
int x = 0; x < vol.
getSizeX(); ++x )
125 if( vol(x, y, z) != trueMin && vol(x, y, z) <
min )
135 std::vector<long> histo( 100, 0 );
136 double histoDelta = double(
max -
min) / 99.;
137 for(
int z = 0; z < vol.
getSizeZ(); ++z )
138 for(
int y = 0; y < vol.
getSizeY(); ++y )
139 for(
int x = 0; x < vol.
getSizeX(); ++x )
141 T val = vol(x, y, z);
143 histo[ int(
double(val -
min) / histoDelta ) ] += 1;
148 while( i99 >= 0 && (
double)
accumulate / histoSize < 1. - pct_kept )
151 max = (T)(
min + histoDelta *
double(i99));
158 min -= util::epsilon<T>();
static T sum(Iterator b, Iterator e)
VolumeRef< T > deepcopy() const
float min(float x, float y)
float max(float x, float y)
carto::VolumeRef< T > clip(const carto::VolumeRef< T > &in, const T &min, const T &max)
\function clip
carto::VolumeRef< T > clipDynamic(const carto::VolumeRef< T > &in, bool flatten_mask=true, float pct_kept=1.)
\function clipDynamic
OUTP accumulate(const Volume< T > &vol, BinaryFunction func, OUTP initial)
Volume< T > deepcopy(const Volume< T > &src, const std::vector< int > &size=std::vector< int >())