Isis Developer Reference
LowPassFilter.h
Go to the documentation of this file.
1#ifndef LowPassFilter_h
2#define LowPassFilter_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12#include <string>
13#include <vector>
14
15#include "IString.h"
16#include "HiCalUtil.h"
17#include "Module.h"
18#include "QuickFilter.h"
19#include "IException.h"
20
21namespace Isis {
22
30 class LowPassFilter : public Module {
31
32 public:
33 // Constructors and Destructor
34 LowPassFilter() : Module("LowPassFilter"), _width(3),
35 _iterations(1) { }
36 LowPassFilter(int width, int iterations = 1) :
37 Module("LowPassFilter"), _width(width), _iterations(iterations) { }
38
39 LowPassFilter(const Module &c, int width = 3, int iterations = 1) :
40 Module("LowPassFilter", c), _width(width),
41 _iterations(iterations) {
42 _data = filterIterator(c.ref(), _width, _iterations);
43 _history.add(formHistory());
44 }
45
46 LowPassFilter(const HiVector &v, const HiHistory &h,
47 int width = 3, int iterations = 1) :
48 Module("LowPassFilter", h), _width(width),
49 _iterations(iterations) {
50 _data = filterIterator(v, _width, _iterations);
51 _history.add(formHistory());
52 }
53
55 virtual ~LowPassFilter() { }
56
57 void Process(const HiVector &v) {
58 _data = filterIterator(v, _width, _iterations);
60 _history.add(formHistory());
61 }
62
63 inline int Width() const { return (_width); }
64
65 private:
66 int _width;
67 int _iterations; // Number iterations to apply filter
68
69 QString formHistory() {
70 return (QString("LowPassFilter(Width[" + ToString(_width) +
71 "],Iters["+ToString(_iterations)+"])"));
72 }
73
74 HiVector filterIterator(const HiVector &v, int width, int iterations) {
75 HiVector vout(v.copy());
76 for (int i = 0 ; i < iterations; i++) {
77 vout = filter(vout,width);
78 }
79 return (vout);
80 }
81
82 HiVector filter(const HiVector &v, int width) {
83 QuickFilter lowpass(v.dim(), width, 1);
84 lowpass.AddLine(&v[0]);
85 HiVector vout(v.dim());
86 for (int i = 0 ; i < v.dim() ; i ++) {
87 vout[i] = lowpass.Average(i);
88 }
89 return (vout);
90 }
91 };
92
93} // namespace Isis
94#endif
Definition HiCalTypes.h:30
void clear()
Definition HiCalTypes.h:65
void add(const QString &event)
Definition HiCalTypes.h:55
Compute a low pass filter from a Module class content.
Definition LowPassFilter.h:30
LowPassFilter(const HiVector &v, const HiHistory &h, int width=3, int iterations=1)
Definition LowPassFilter.h:46
LowPassFilter(int width, int iterations=1)
Definition LowPassFilter.h:36
void Process(const HiVector &v)
Default processing behavior makes a reference copy of data array.
Definition LowPassFilter.h:57
virtual ~LowPassFilter()
Destructor.
Definition LowPassFilter.h:55
int Width() const
Definition LowPassFilter.h:63
LowPassFilter(const Module &c, int width=3, int iterations=1)
Definition LowPassFilter.h:39
LowPassFilter()
Definition LowPassFilter.h:34
Module manages HiRISE calibration vectors from various sources.
Definition Module.h:39
HiVector _data
Data vector.
Definition Module.h:151
HiHistory _history
Hierarchial component history.
Definition Module.h:152
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
TNT::Array1D< double > HiVector
1-D Buffer
Definition HiCalTypes.h:27
QString ToString(const T &value)
Helper function to convert values to strings.
Definition HiCalUtil.h:236