Puts everything in a namespace
This commit is contained in:
parent
41869d8cb0
commit
0fcfd492f8
3 changed files with 128 additions and 98 deletions
|
@ -4,23 +4,11 @@
|
||||||
|
|
||||||
#include "striding_iterator.hpp"
|
#include "striding_iterator.hpp"
|
||||||
#include "periodic_iterator.hpp"
|
#include "periodic_iterator.hpp"
|
||||||
|
#include "wavelet_constants.hpp"
|
||||||
|
|
||||||
static double const evn_coef[] = {
|
namespace wvlt {
|
||||||
(1.0 + std::sqrt(3.0))/(std::sqrt(32.0)),
|
namespace V1 {
|
||||||
(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]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply the matrix Wn with the DAUB4 coefficients
|
// Apply the matrix Wn with the DAUB4 coefficients
|
||||||
// Assumes input to be periodic
|
|
||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
void wavelet_mul(Iterator begin, Iterator end){
|
void wavelet_mul(Iterator begin, Iterator end){
|
||||||
auto mul = end - begin;
|
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>
|
template <typename Iterator>
|
||||||
void wavelet_inv(Iterator begin, Iterator end){
|
void wavelet_inv(Iterator begin, Iterator end){
|
||||||
auto mul = end - begin;
|
auto mul = end - begin;
|
||||||
|
@ -109,3 +98,5 @@ void unwavelet(Iterator begin, Iterator end){
|
||||||
wavelet_inv(begin, end);
|
wavelet_inv(begin, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "periodic_iterator.hpp"
|
#include "periodic_iterator.hpp"
|
||||||
#include "wavelet.hpp"
|
#include "wavelet.hpp"
|
||||||
|
|
||||||
|
using namespace wvlt::V1;
|
||||||
|
|
||||||
// note: we take a copy, because we will modify it in place
|
// 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){
|
jcmp::image compress(std::vector<double> image, int width, double threshold, int& zeros){
|
||||||
auto height = image.size() / width;
|
auto height = image.size() / width;
|
||||||
|
|
|
@ -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]
|
||||||
|
};
|
||||||
|
}
|
Reference in a new issue