(committing very old stuff) No clue what has changed
This commit is contained in:
parent
da326204c9
commit
553eff00e3
6 changed files with 20 additions and 16 deletions
|
@ -109,14 +109,15 @@ int main(){
|
||||||
|
|
||||||
// compress and decompress to see how we lost information
|
// compress and decompress to see how we lost information
|
||||||
unsigned int nzeros = 0;
|
unsigned int nzeros = 0;
|
||||||
auto compressed_vec = decompress(compress(image_vec, width, 0.5, nzeros));
|
auto compressed_vec = decompress(compress(image_vec, width, 5.0, nzeros));
|
||||||
|
|
||||||
// output some information
|
// output some information
|
||||||
std::cout << field("raw") << human_string(sizeof(uint8_t) * image_vec.size(), "b") << std::endl;
|
std::cout << field("raw") << width*height << std::endl;
|
||||||
std::cout << field("compressed") << human_string(sizeof(jcmp::coefficient) * nzeros, "b") << std::endl;
|
std::cout << field("compressed") << nzeros/double(width*height) << std::endl;
|
||||||
|
std::cout << field("nz") << nzeros << std::endl;
|
||||||
|
|
||||||
// save to output file
|
// save to output file
|
||||||
std::string cfilename = "compressed/" + path.filename().string();
|
std::string cfilename = "compressed/" + std::to_string(nzeros) + path.filename().string();
|
||||||
png::gray_ostream compressed_image(width, height, cfilename);
|
png::gray_ostream compressed_image(width, height, cfilename);
|
||||||
for(unsigned int i = 0; i < compressed_vec.size(); ++i) compressed_image << compressed_vec[i];
|
for(unsigned int i = 0; i < compressed_vec.size(); ++i) compressed_image << compressed_vec[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ namespace wvlt{
|
||||||
// x1 and x2 are next elements, or wrap around
|
// x1 and x2 are next elements, or wrap around
|
||||||
// calculates size/stride elements of the output
|
// calculates size/stride elements of the output
|
||||||
inline void wavelet_mul(double* x, double x1, double x2, unsigned int size, unsigned int stride){
|
inline void wavelet_mul(double* x, double x1, double x2, unsigned int size, unsigned int stride){
|
||||||
assert(x && is_even(size) && is_pow_of_two(stride) && 4*stride <= size);
|
assert(x && is_even(size) && is_pow_of_two(stride) && 2*stride <= size);
|
||||||
|
if(4*stride <= size)
|
||||||
wavelet_mul_base(x, size, stride);
|
wavelet_mul_base(x, size, stride);
|
||||||
|
|
||||||
unsigned int i = size - 2*stride;
|
unsigned int i = size - 2*stride;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace wvlt {
|
||||||
unsigned int n, b, m, Cm, small_steps, big_steps, remainder;
|
unsigned int n, b, m, Cm, small_steps, big_steps, remainder;
|
||||||
|
|
||||||
plan_1D(unsigned int n_, unsigned int b_, unsigned int m_)
|
plan_1D(unsigned int n_, unsigned int b_, unsigned int m_)
|
||||||
: n(n_), b(b_), m(m_), Cm(pow_two(m+1) - 2), small_steps(two_log(b) - 1), big_steps(small_steps/m), remainder(small_steps - m*big_steps)
|
: n(n_), b(b_), m(m_), Cm(pow_two(m+1) - 2), small_steps(two_log(b)), big_steps((small_steps-1)/m), remainder(small_steps - m*big_steps)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,20 +81,19 @@ namespace wvlt {
|
||||||
// First do the local part
|
// First do the local part
|
||||||
base(d, plan, x, next, plan.b);
|
base(d, plan, x, next, plan.b);
|
||||||
|
|
||||||
|
// we only have to finish centralized if p >= 4
|
||||||
|
if(d.p <= 2) return;
|
||||||
|
|
||||||
// Then do a fan in (i.e. 2 elements to proc zero)
|
// Then do a fan in (i.e. 2 elements to proc zero)
|
||||||
for(unsigned int i = 0; i < 2; ++i){
|
bsp::put(0, x, proczero, d.s);
|
||||||
bsp::put(0, &x[i * plan.b/2], proczero, d.s * 2 + i);
|
|
||||||
}
|
|
||||||
bsp::sync();
|
bsp::sync();
|
||||||
|
|
||||||
// proc zero has the privilige/duty to finish the job
|
// proc zero has the privilige/duty to finish the job
|
||||||
if(d.s == 0) {
|
if(d.s == 0) {
|
||||||
wvlt::wavelet(proczero, 2*d.p, 1);
|
wvlt::wavelet(proczero, d.p, 1);
|
||||||
// and to send it back to everyone
|
// and to send it back to everyone
|
||||||
for(unsigned int t = 0; t < d.p; ++t){
|
for(unsigned int t = 0; t < d.p; ++t){
|
||||||
for(unsigned int i = 0; i < 2; ++i){
|
bsp::put(t, &proczero[t], x);
|
||||||
bsp::put(t, &proczero[t*2 + i], x, i * plan.b/2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void par_wavelet(){
|
||||||
// For convenience and consistency we use std::vector
|
// For convenience and consistency we use std::vector
|
||||||
std::vector<double> x(plan.b, 0.0);
|
std::vector<double> x(plan.b, 0.0);
|
||||||
std::vector<double> next(plan.Cm, 0.0);
|
std::vector<double> next(plan.Cm, 0.0);
|
||||||
std::vector<double> proczero(d.s == 0 ? 2*d.p : 1, 0.0);
|
std::vector<double> proczero(d.s == 0 ? d.p : 1, 0.0);
|
||||||
|
|
||||||
bsp::push_reg(x.data(), x.size());
|
bsp::push_reg(x.data(), x.size());
|
||||||
bsp::push_reg(next.data(), next.size());
|
bsp::push_reg(next.data(), next.size());
|
||||||
|
|
|
@ -12,3 +12,4 @@ As for the application of image compression, we have seen that the wavelets capt
|
||||||
\includegraphics[width=0.3\textwidth]{parijs.png}
|
\includegraphics[width=0.3\textwidth]{parijs.png}
|
||||||
\caption{My girlfriend and I in Paris. Still romantic with only 200 coefficients.}
|
\caption{My girlfriend and I in Paris. Still romantic with only 200 coefficients.}
|
||||||
\end{figure}
|
\end{figure}
|
||||||
|
\vspace{3cm}
|
||||||
|
|
|
@ -21,7 +21,9 @@ In this paper we will derive a parallel algorithm to perform a Daubechies wavele
|
||||||
\include{par}
|
\include{par}
|
||||||
\include{img}
|
\include{img}
|
||||||
\include{res}
|
\include{res}
|
||||||
\include{conc}
|
|
||||||
|
\newpage
|
||||||
|
\input{conc}
|
||||||
|
|
||||||
|
|
||||||
\nocite{*}
|
\nocite{*}
|
||||||
|
|
Reference in a new issue