File: filter_rot.cpp

package info (click to toggle)
odin 2.0.5-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,196 kB
  • sloc: cpp: 62,638; sh: 4,541; makefile: 779
file content (54 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (8)
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
#include "filter_rot.h"

#include "gridding.h"

void FilterRot::init(){

  angle=0.0;
  angle.set_unit("deg").set_description("angle");
  append_arg(angle,"angle");

  kernel=sqrt(2.0);
  kernel.set_unit("pixel").set_description("kernel size");
  append_arg(kernel,"kernel");
}

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

  Range all=Range::all();

  ODINLOG(odinlog,normalDebug) << "angle=" << angle << STD_endl;

  RotMatrix rotmat;
  rotmat.set_inplane_rotation(angle*PII/180.0);
  ODINLOG(odinlog,normalDebug) << "rotmat=" << rotmat.print() << STD_endl;


  TinyVector<float,2> offset=0.0;
  TinyMatrix<float,2,2> rotation;
  for(int irow=0; irow<2; irow++) {
    for(int icol=0; icol<2; icol++) {
      rotation(1-irow,1-icol)=rotmat[irow][icol];
    }
  }

  CoordTransformation<float,2> transform(TinyVector<int,2>(data.extent(phaseDim),data.extent(readDim)), rotation, offset, kernel);

  for(int irep=0; irep<data.extent(timeDim); irep++) {
    for(int islice=0; islice<data.extent(sliceDim); islice++) {
      data(irep,islice,all,all)=transform(data(irep,islice,all,all));
    }
  }

  // Adjust protocol
  Geometry& geo=prot.geometry;
  geo.set_orientation_and_offset(
    rotmat*geo.get_readVector(),
    rotmat*geo.get_phaseVector(),
    rotmat*geo.get_sliceVector(),
    geo.get_center()
  );

  return true;
}