|
@ -23,10 +23,15 @@ static image compress(std::vector<double> const & img0, uint16_t width, double t |
|
|
assert(width == height); |
|
|
assert(width == height); |
|
|
|
|
|
|
|
|
std::vector<double> img(img0.size(), 0); |
|
|
std::vector<double> img(img0.size(), 0); |
|
|
|
|
|
std::vector<double> weights(img0.size(), 0); |
|
|
|
|
|
|
|
|
for(uint16_t y = 0; y < height; y++){ |
|
|
for(uint16_t y = 0; y < height; y++){ |
|
|
for(uint16_t x = 0; x < width; x++) { |
|
|
for(uint16_t x = 0; x < width; x++) { |
|
|
img[remap::to_hilbert(width, x, y)] = img0[x + y*width]; |
|
|
img[remap::to_hilbert(width, x, y)] = img0[x + y*width]; |
|
|
|
|
|
|
|
|
|
|
|
const double xx = (x + 0.5 - 2120) / double(width); |
|
|
|
|
|
const double yy = (y + 0.5 - 1624) / double(height); |
|
|
|
|
|
weights[remap::to_hilbert(width, x, y)] = xx*xx + yy*yy; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -47,9 +52,11 @@ static image compress(std::vector<double> const & img0, uint16_t width, double t |
|
|
double min_abs = 10000.0; |
|
|
double min_abs = 10000.0; |
|
|
double max_abs = 0.0; |
|
|
double max_abs = 0.0; |
|
|
|
|
|
|
|
|
for(auto& el : img){ |
|
|
for(size_t i = 0; i < img.size(); ++i){ |
|
|
auto absel = std::abs(el); |
|
|
auto & el = img[i]; |
|
|
if(absel > threshold) { |
|
|
const auto w = weights[i]; |
|
|
|
|
|
const auto absel = std::abs(el); |
|
|
|
|
|
if(absel > w*threshold) { |
|
|
min_abs = std::min(min_abs, absel); |
|
|
min_abs = std::min(min_abs, absel); |
|
|
max_abs = std::max(max_abs, absel); |
|
|
max_abs = std::max(max_abs, absel); |
|
|
} else { |
|
|
} else { |
|
@ -172,11 +179,12 @@ int main(int argc, char* argv[]){ |
|
|
|
|
|
|
|
|
auto width = image.get_width(); |
|
|
auto width = image.get_width(); |
|
|
auto height = image.get_height(); |
|
|
auto height = image.get_height(); |
|
|
|
|
|
std::cout << field("size") << width << "x" << height << std::endl; |
|
|
|
|
|
|
|
|
// read into vector
|
|
|
// read into vector
|
|
|
std::vector<double> image_vec; |
|
|
std::vector<double> image_vec; |
|
|
image_vec.reserve(width * height); |
|
|
image_vec.reserve(width * height); |
|
|
for(unsigned char c = 0; image >> c;) image_vec.push_back(c/255.0); |
|
|
for(unsigned char c = 0; image >> c;) image_vec.push_back(c/255.0); |
|
|
|
|
|
|
|
|
// 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; |
|
|