File: filter_tile.cpp

package info (click to toggle)
odin 2.0.5-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,224 kB
  • sloc: cpp: 62,639; sh: 4,541; makefile: 779
file content (58 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "filter_tile.h"

void FilterTile::init(){
  cols.set_description("columns");
  append_arg(cols,"cols");
}


bool FilterTile::process(Data<float,4>& data, Protocol& prot) const {
  Log<Filter> odinlog(c_label(),"process");

  Range all=Range::all();

  int nrep=data.extent(0);
  int nslice=data.extent(1);
  int nphase=data.extent(2);
  int nread=data.extent(3);

  int tilecols=cols;
  tilecols=STD_max(tilecols,1);
  tilecols=STD_min(tilecols,nslice);


  int rows=nslice/tilecols;
  if(nslice%tilecols) rows++;

  ODINLOG(odinlog,normalDebug) << "nslice/cols/rows=" << nslice << "/" << tilecols << "/" << rows << STD_endl;

  int newnphase=rows*nphase;
  int newnread=tilecols*nread;

  Data<float,4> outdata(nrep,1,newnphase,newnread); outdata=0.0;

  int icol=0;
  int irow=0;
  for(int islice=0; islice<nslice; islice++) {

    int rowoffset=irow*nphase;
    int coloffset=icol*nread;
    outdata(all, 0, Range(rowoffset, rowoffset+nphase-1), Range(coloffset, coloffset+nread-1))=data(all,islice,all,all);

    icol++;
    if(icol>=tilecols) {
      icol=0;
      irow++;
    }
  }

  data.reference(outdata);

  // adjust protocol
  prot.geometry.set_nSlices(1);
  prot.seqpars.set_MatrixSize(phaseDirection,newnphase);
  prot.seqpars.set_MatrixSize(readDirection,newnread);


  return true;
}