Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Done some work regarding third window combining method

  • Loading branch information...
commit d5d0ef5c607645b2cab9f1facea676c423636698 1 parent bc4f3e9
@prasko authored
View
6 src/adwt.cpp
@@ -69,11 +69,11 @@ void adwt(signal &input, signal &A, signal &D) {
// guess parameter b = Yd(z) / U(z)
Lpw *lsw = new Lsw(yd, x4);
- // ConfidenceInterval *ci = new ConfidenceInterval(0.005);
+ // ConfidenceInterval *ci = new ConfidenceInterval(0.005);
// ConfidenceInterval *ci = new TunnelInterval(0.05, 0.005, 0.005);
// WindowCombiner *wc = new SimpleWindowCombiner(*lsw, *ci);
-
- WindowCombiner *wc = new ICIWindowCombiner(*lsw);
+ //WindowCombiner *wc = new ICIWindowCombiner(*lsw);
+ WindowCombiner *wc = new DenoiserWindowCombiner(*lsw);
signal b_res;
wc->combine(b_res);
View
38 src/combine.cpp
@@ -10,25 +10,45 @@
#include "combine.h"
#include "denoise.h"
-void DenoiserWindowCombiner::combiner(std::vector<double> &res) {
+void DenoiserWindowCombiner::combine(std::vector<double> &res) {
+ TwoWayICIDenoiser denoiser;
int n = lpw_.length();
- std::vector<signal> params;
- std::vector<TwoWayICIDenoiser*> intervals;
+ std::vector<double> ratios(n);
+ res.resize(n);
- for(int wsize = 10; wsize < n/10; wsize = (int)(1.31 * wsize)) {
+ double ilr_ratio;
+
+ for(int wsize = 100; wsize < n/10; wsize = (double)1.31 * wsize) {
std::vector<double> windowed_signal;
+ fprintf(stderr, "%d\n", wsize);
+
for(int i = 0; i < n; ++i) {
windowed_signal.push_back(lpw_.getCoef(wsize, i));
}
+
+ signal params;
+ denoiser.denoise(windowed_signal, params);
+
+ const std::vector<int> &right = denoiser.intervalRight();
+ const std::vector<int> &left = denoiser.intervalLeft();
+
+ for(int i = 0; i < n; ++i) {
+ ilr_ratio = 1.0 / std::min((double)right[i] / left[i],
+ (double)left[i] / right[i]);
- intervals.push_back(new TwoWayICIDenoiser());
- params.push_back(signal());
- intervals.back()->denoise(windowed_signal, params.back());
+ res[i] += ilr_ratio * params[i];
+ ratios[i] += ilr_ratio;
+ }
}
-
+ // za pojedini wsize, pomnozim vrijednosti parametara sa min(il/ir, ir/il)
+ // onda to sve zbrojim i pomnozim sa sumom svih tih min
+
+ for(int i = 0; i < n; ++i) {
+ res[i] /= ratios[i];
+ }
}
void SimpleWindowCombiner::combine(std::vector<double> &res) {
@@ -133,7 +153,7 @@ void ICIWindowCombiner::combine_(
rk = (minub - maxlb) / (2 * gama * sigma);
- if(minub < maxlb || rk < rc) break; // ICI or RICI
+ if(minub < maxlb) break;// || rk < rc) break; // ICI or RICI
avg = tavg;
}
View
2  src/combine.h
@@ -24,7 +24,7 @@ class WindowCombiner {
class DenoiserWindowCombiner : public WindowCombiner {
public:
DenoiserWindowCombiner(Lpw &lpw) : WindowCombiner(lpw) {}
- void combiner(std::vector<double> &result);
+ void combine(std::vector<double> &result);
};
class ICIWindowCombiner : public WindowCombiner {
View
2  src/denoise.cpp
@@ -36,7 +36,7 @@ void OneWayICIDenoiser::denoise(const signal &sig, signal &res) {
sum += sig[n+k-1];
tavg = sum / k;
- sigma = sigma_noise / k;
+ sigma = sigma_noise / sqrt(k);
minub = std::min(minub, tavg + gama * sigma);
maxlb = std::max(maxlb, tavg - gama * sigma);
Please sign in to comment.
Something went wrong with that request. Please try again.