Authors belong to:
- University of LYON http://www.universite-lyon.fr/
- - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ - Léon Bérard cancer center http://www.centreleonberard.fr
- CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
This software is distributed WITHOUT ANY WARRANTY; without even
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
#ifndef clitkMedianTemporalDimensionGenericFilter_txx
#define clitkMedianTemporalDimensionGenericFilter_txx
// Take the median
double value;
+ typename InputImageType::IndexValueType temporal_dimension = size4D[Dimension-1];
+ std::vector<PixelType> temp(temporal_dimension);
while (!(iterators[0]).IsAtEnd()) {
value=0.;
- std::vector<PixelType> temp;
- for (unsigned int i=0; i<size4D[Dimension-1]; i++) {
- temp.push_back(iterators[i].Get());
+ for (unsigned int i=0; i<temporal_dimension; i++) {
+ temp[i] = iterators[i].Get();
++(iterators[i]);
}
- if (temp.size() % 2) {
- nth_element(temp.begin(),temp.begin()+((temp.size()-1)/2+1),temp.end());
- value=temp[(temp.size()-1)/2];
+ if (temporal_dimension & 1) {
+ nth_element(temp.begin(), temp.begin() + temporal_dimension/2,temp.end());
+ value = temp[temporal_dimension/2];
} else {
- nth_element(temp.begin(),temp.begin()+(temp.size())/2,temp.end());
- value=temp[temp.size()/2];
- nth_element(temp.begin(),temp.begin()+ (temp.size()/2+1),temp.end());
- value+=temp[temp.size()/2+1];
- value/=2;
+ nth_element(temp.begin(), temp.begin() + temporal_dimension/2 - 1, temp.end());
+ value = temp[temporal_dimension/2 - 1];
+ nth_element(temp.begin(), temp.begin() + temporal_dimension/2, temp.end());
+ value += temp[temporal_dimension/2];
+ value /= 2;
}
- value/=size4D[Dimension-1];
avIt.Set(value);
++avIt;
}