no idea, had some changes
This commit is contained in:
parent
0b6f80473a
commit
fe611907ea
4 changed files with 35 additions and 19 deletions
|
@ -4,21 +4,24 @@ project(compress)
|
||||||
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/include/")
|
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/include/")
|
||||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
|
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
|
||||||
|
|
||||||
|
option(EnableBSP "Building with BSP" OFF)
|
||||||
option(MultiCoreBSP "Building with Multi Core BSP" ON)
|
option(MultiCoreBSP "Building with Multi Core BSP" ON)
|
||||||
|
if(EnableBSP)
|
||||||
if(MultiCoreBSP)
|
if(MultiCoreBSP)
|
||||||
# setup for my mac
|
# setup for my mac
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
set(libs mcbsp m pthread)
|
set(libs mcbsp m pthread)
|
||||||
add_definitions( -DUSE_MCBSP )
|
add_definitions( -DUSE_MCBSP )
|
||||||
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/contrib/mcbsp")
|
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/contrib/mcbsp")
|
||||||
|
add_subdirectory("contrib/mcbsp")
|
||||||
else()
|
else()
|
||||||
# setup for cartesius
|
# setup for cartesius
|
||||||
set(libs bsponmpi m)
|
set(libs bsponmpi m)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Boost REQUIRED COMPONENTS program_options filesystem system)
|
find_package(Boost REQUIRED COMPONENTS program_options filesystem system)
|
||||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||||
set(libs ${libs} ${Boost_LIBRARIES})
|
set(libs ${libs} ${Boost_LIBRARIES})
|
||||||
|
|
||||||
add_subdirectory("wavelet")
|
add_subdirectory("wavelet")
|
||||||
add_subdirectory("contrib/mcbsp")
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace png{
|
||||||
throw std::runtime_error("Interalced PNG's are not supported");
|
throw std::runtime_error("Interalced PNG's are not supported");
|
||||||
|
|
||||||
height = png_get_image_height(png_ptr, info_ptr);
|
height = png_get_image_height(png_ptr, info_ptr);
|
||||||
auto width = png_get_image_width(png_ptr, info_ptr);
|
width = png_get_image_width(png_ptr, info_ptr);
|
||||||
auto bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
auto bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
auto channels = png_get_channels(png_ptr, info_ptr);
|
auto channels = png_get_channels(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace png{
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_width() const { return row.size(); }
|
uint32_t get_width() const { return width; }
|
||||||
uint32_t get_height() const { return height; }
|
uint32_t get_height() const { return height; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -184,6 +184,7 @@ namespace png{
|
||||||
uint32_t stride;
|
uint32_t stride;
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
uint32_t y;
|
uint32_t y;
|
||||||
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
if(EnableBSP)
|
||||||
file(GLOB sources *.cpp)
|
file(GLOB sources *.cpp)
|
||||||
file(GLOB headers *.hpp)
|
file(GLOB headers *.hpp)
|
||||||
|
else()
|
||||||
|
set(sources jcmp.cpp jcmp_image_test.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
include_directories(SYSTEM ${PNG_INCLUDE_DIRS})
|
include_directories(SYSTEM ${PNG_INCLUDE_DIRS})
|
||||||
|
|
|
@ -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,6 +179,7 @@ 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;
|
||||||
|
|
Reference in a new issue