18 #ifndef FILTER_REDUCTION_H
19 #define FILTER_REDUCTION_H
22 #include <odindata/filter_step.h>
24 enum reductionOp { minip=0, maxip, meanp, sump };
25 static const char* reductionOpLabel[]={
"minip",
"maxip",
"proj",
"sum"};
32 STD_string
label()
const {
return reductionOpLabel[Op];}
36 if(Op==minip) opstr=
"minimum intensity ";
37 if(Op==maxip) opstr=
"maximum intensity ";
38 if(Op==meanp) opstr=
"mean ";
39 if(Op==sump) opstr=
"sum ";
40 return "Perform "+opstr+
"projection over given direction";
44 for(
int i=0; i<n_dataDim; i++) dir.add_item(dataDimLabel[i]);
45 dir.add_item(ODIN_NONE_STR);
46 dir.set_actual(dir.n_items()-1);
47 dir.set_cmdline_option(
"dir").set_description(
"direction");
54 if(dir==ODIN_NONE_STR){
55 ODINLOG(odinlog,errorLog) <<
"no valid dimension given" << STD_endl;
59 TinyVector<int,4> inshape=data.shape();
61 TinyVector<int,4> outshape=data.shape();
66 for(
unsigned int i=0; i<outdata.size(); i++) {
67 TinyVector<int,4> index=outdata.create_index(i);
69 TinyVector<int,4> lowerBounds=index;
70 TinyVector<int,4> upperBounds=index;
71 upperBounds(dir)=inshape(dir)-1;
73 if(Op==minip) outdata(index)=min (data(RectDomain<4>(lowerBounds, upperBounds)));
74 if(Op==maxip) outdata(index)=max (data(RectDomain<4>(lowerBounds, upperBounds)));
75 if(Op==meanp) outdata(index)=mean(data(RectDomain<4>(lowerBounds, upperBounds)));
76 if(Op==sump) outdata(index)=sum (data(RectDomain<4>(lowerBounds, upperBounds)));
79 data.reference(outdata);
virtual bool process(Data< float, 4 > &data, Protocol &prot) const
Geometry & set_nSlices(unsigned int nslices)
SeqPars & set_MatrixSize(direction dir, unsigned int size, parameterMode parmode=edit)
SeqPars & set_NumOfRepetitions(unsigned int times, parameterMode parmode=edit)
virtual FilterStep * allocate() const=0
void append_arg(LDRbase &arg, const STD_string &arglabel)
virtual STD_string description() const=0
virtual STD_string label() const=0