Browse Source

Puts everything in a namespace

master
Joshua Moerman 11 years ago
parent
commit
0fcfd492f8
  1. 21
      wavelet/wavelet.hpp
  2. 2
      wavelet/wavelet2.cpp
  3. 37
      wavelet/wavelet_constants.hpp

21
wavelet/wavelet.hpp

@ -4,23 +4,11 @@
#include "striding_iterator.hpp"
#include "periodic_iterator.hpp"
#include "wavelet_constants.hpp"
static double const evn_coef[] = {
(1.0 + std::sqrt(3.0))/(std::sqrt(32.0)),
(3.0 + std::sqrt(3.0))/(std::sqrt(32.0)),
(3.0 - std::sqrt(3.0))/(std::sqrt(32.0)),
(1.0 - std::sqrt(3.0))/(std::sqrt(32.0))
};
static double const odd_coef[] = {
evn_coef[3],
-evn_coef[2],
evn_coef[1],
-evn_coef[0]
};
namespace wvlt {
namespace V1 {
// Apply the matrix Wn with the DAUB4 coefficients
// Assumes input to be periodic
template <typename Iterator>
void wavelet_mul(Iterator begin, Iterator end){
auto mul = end - begin;
@ -34,6 +22,7 @@ void wavelet_mul(Iterator begin, Iterator end){
}
}
// Apply inverse of the matrix Wn with the DAUB4 coefficients
template <typename Iterator>
void wavelet_inv(Iterator begin, Iterator end){
auto mul = end - begin;
@ -109,3 +98,5 @@ void unwavelet(Iterator begin, Iterator end){
wavelet_inv(begin, end);
}
}
}
}

2
wavelet/wavelet2.cpp

@ -9,6 +9,8 @@
#include "periodic_iterator.hpp"
#include "wavelet.hpp"
using namespace wvlt::V1;
// note: we take a copy, because we will modify it in place
jcmp::image compress(std::vector<double> image, int width, double threshold, int& zeros){
auto height = image.size() / width;

37
wavelet/wavelet_constants.hpp

@ -0,0 +1,37 @@
#pragma once
#include <cmath>
namespace wvlt {
// first row of the matrix Wn
static double const evn_coef[] = {
(1.0 + std::sqrt(3.0))/(std::sqrt(32.0)),
(3.0 + std::sqrt(3.0))/(std::sqrt(32.0)),
(3.0 - std::sqrt(3.0))/(std::sqrt(32.0)),
(1.0 - std::sqrt(3.0))/(std::sqrt(32.0))
};
// second row of the matrix Wn
static double const odd_coef[] = {
evn_coef[3],
-evn_coef[2],
evn_coef[1],
-evn_coef[0]
};
// first (shifted) row of the matrix Wn^-1
static double const evn_coef_inv[] = {
evn_coef[2],
evn_coef[1],
evn_coef[0],
evn_coef[3]
};
// second (shifted) row of the matrix Wn^-1
static double const odd_coef_inv[] = {
evn_coef[3],
-evn_coef[0],
evn_coef[1],
-evn_coef[2]
};
}