isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Sequential.h
1 // -*- C++ -*-
2 // -*- coding: utf-8 -*-
3 //
4 // michael a.g. aïvázis <michael.aivazis@para-sim.com>
5 // parasim
6 // (c) 1998-2019 all rights reserved
7 
8 #pragma once
9 
10 // resource management and orchestration of the execution of the correlation plan
11 template <typename raster_t>
13  // types
14 public:
15  // my client raster type
16  using raster_type = raster_t;
17  // views over it
18  using view_type = typename raster_type::view_type;
19  using constview_type = typename raster_type::constview_type;
20  // the underlying pixel complex type
21  using cell_type = typename raster_type::cell_type;
22  // the support of the pixel complex type
23  using value_type = typename cell_type::value_type;
24  // for describing slices of rasters
25  using slice_type = typename raster_type::slice_type;
26  // for describing the shapes of tiles
27  using shape_type = typename raster_type::shape_type;
28  // for describing the layouts of tiles
29  using layout_type = typename raster_type::layout_type;
30  // for index arithmetic
31  using index_type = typename raster_type::index_type;
32  // for sizing things
33  using size_type = typename raster_type::size_type;
34 
35  // adapter for tiles within my arena
36  using tile_type = pyre::grid::grid_t<cell_type,
37  layout_type,
38  pyre::memory::view_t<cell_type>>;
39 
40  // interface
41 public:
42  // add a reference tile to the pile
43  inline void addReferenceTile(size_type pid, const constview_type & ref);
44  // add a target search window to the pile
45  inline void addTargetTile(size_type pid, const constview_type & tgt);
46 
47  // compute adjustments to the offset map
48  inline auto adjust() -> const value_type *;
49 
50  // accessors
51  inline auto pairs() const -> size_type;
52  inline auto arena() const -> const cell_type *;
53 
54  // debugging support
55  inline void dump() const;
56 
57  // meta-methods
58 public:
59  inline ~Sequential();
60  inline Sequential(size_type pairs,
61  const layout_type & refLayout, const layout_type & tgtLayout,
62  size_type refineFactor=2, size_type refineMargin=8,
63  size_type zoomFactor=4);
64 
65  // implementation details: methods
66 public:
67  // push the tiles in the plan to device
68  inline auto _push() const -> cell_type *;
69  // compute the magnitude of the complex signal pixel-by-pixel
70  inline auto _detect(const cell_type * cArena,
71  size_type refDim, size_type tgtDim) const -> value_type *;
72  // subtract the mean from reference tiles and compute the square root of their variance
73  inline auto _refStats(value_type * rArena,
74  size_type refDim, size_type tgtDim) const -> value_type *;
75  // compute the sum area tables for the target tiles
76  inline auto _sat(const value_type * rArena,
77  size_type refDim, size_type tgtDim) const -> value_type *;
78  // compute the mean of all possible placements of a tile the same size as the reference
79  // tile within the target
80  inline auto _tgtStats(const value_type * sat,
81  size_type refDim, size_type tgtDim, size_type corDim
82  ) const -> value_type *;
83  // correlate
84  inline auto _correlate(const value_type * rArena,
85  const value_type * refStats, const value_type * tgtStats,
86  size_type refDim, size_type tgtDim, size_type corDim
87  ) const -> value_type *;
88  // find the locations of the maxima of the correlation matrix
89  inline auto _maxcor(const value_type * gamma, size_type corDim) const -> int *;
90  // adjust the locations of the maxima so that the refined tile sources fit with the target
91  inline void _nudge(int * locations, size_type refDim, size_type tgtDim) const;
92  // allocate memory for a new arena big enough to hold the refined tiles
93  inline auto _refinedArena() const -> cell_type *;
94  // refine the reference tiles
95  inline void _refRefine(cell_type * coarseArena, cell_type * refinedArena) const;
96  // migrate the expanded unrefined target tiles into the {refinedArena}
97  inline void _tgtMigrate(cell_type * coarseArena, int * locations,
98  cell_type * refinedArena) const;
99  // refine the target tiles
100  inline void _tgtRefine(cell_type * refinedArena) const;
101  // deramp
102  inline void _deramp(cell_type * arena) const;
103  // zoom the correlation matrix
104  inline auto _zoomcor(value_type * gamma) const -> value_type *;
105  // assemble the offsets
106  inline auto _offsetField(const int * maxcor, const int * zoomed) -> const value_type *;
107 
108  // unfinished correlation matrix zoom that uses R2C and C2R
109  inline auto _zoomcor_r2r(value_type * gamma) const -> value_type *;
110 
111 
112  // implementation details: data
113 private:
114  // my capacity, in {ref/tgt} pairs
115  const size_type _pairs;
116  const size_type _refineFactor;
117  const size_type _refineMargin;
118  const size_type _zoomFactor;
119 
120  // the shape of the reference tiles
121  const layout_type _refLayout;
122  // the shape of the search windows in the target image
123  const layout_type _tgtLayout;
124  // the shape of the correlation matrix
125  const layout_type _corLayout;
126  // the shape of the reference tiles after refinement
127  const layout_type _refRefinedLayout;
128  // the shape of the target tiles after refinement
129  const layout_type _tgtRefinedLayout;
130  // the shape of the correlation matrix after refinement
131  const layout_type _corRefinedLayout;
132  // the shape of the correlation matrix after zooming
133  const layout_type _corZoomedLayout;
134 
135  // the number of cells in a reference tile
136  const size_type _refCells;
137  // the number of cells in a target search window
138  const size_type _tgtCells;
139  // the number of cell in a correlation matrix
140  const size_type _corCells;
141  // the number of cells in a refined reference tile
142  const size_type _refRefinedCells;
143  // the number of cells in a refined target tile
144  const size_type _tgtRefinedCells;
145 
146  // the number of bytes in a reference tile
147  const size_type _refFootprint;
148  // the number of bytes in a target search window
149  const size_type _tgtFootprint;
150  // the number of bytes in a correlation matrix
151  const size_type _corFootprint;
152  // the number of bytes in a refined reference tile
153  const size_type _refRefinedFootprint;
154  // the number of bytes in a refined target tile
155  const size_type _tgtRefinedFootprint;
156 
157  // host storage for the tile pairs
158  cell_type * const _arena;
159  // host storage for the offset field
160  value_type * const _offsets;
161 };

Generated for ISCE3.0 by doxygen 1.8.5.