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>
116 max = *std::max_element( vol.
begin(), vol.
end() );
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 )
130 min = *std::min_element( vol.
begin(), vol.
end() );
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 )
150 accumulate += histo[i99];
151 max = (T)(min + histoDelta *
double(i99));
158 min -= util::epsilon<T>();
160 clip( vol, min, max );
166 #endif // AIMSALGO_REGISTRATION_PREPROCESSING_D_H float min(float x, float y)
VolumeRef< T > deepcopy() const
carto::VolumeRef< T > clip(const carto::VolumeRef< T > &in, const T &min, const T &max)
clip
float max(float x, float y)
carto::VolumeRef< T > clipDynamic(const carto::VolumeRef< T > &in, bool flatten_mask=true, float pct_kept=1.)
clipDynamic
Volume< T > deepcopy(const Volume< T > &src)
static T sum(Iterator b, Iterator e)
OUTP accumulate(const Volume< T > &vol, BinaryFunction func, OUTP initial)