diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-01 03:25:40 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-01 03:25:40 +0200 |
commit | e6518bd1e326aea2ea776282259e8af6cfce61d3 (patch) | |
tree | b0e602472a253ded8d70e38bdca43c15839f71bb | |
parent | 77dc8a9f380d77cb2e497a060c15685b7e27a78b (diff) |
.
-rw-r--r-- | big-atlas-tool/big-atlas.cpp | 13 | ||||
-rw-r--r-- | big-atlas-tool/big-atlas.hpp | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/big-atlas-tool/big-atlas.cpp b/big-atlas-tool/big-atlas.cpp index 4bfe5eea..50a659a3 100644 --- a/big-atlas-tool/big-atlas.cpp +++ b/big-atlas-tool/big-atlas.cpp @@ -21,19 +21,26 @@ std::vector<big_atlas_frame> big_atlas_builder::add_atlas(const std::filesystem: if (mat.type() == CV_8UC3) { cv::Mat mat2; cv::cvtColor(mat, mat2, cv::COLOR_RGB2RGBA); - mat = mat2.clone(); + mat = std::move(mat2); } Error{} << "file" << filename; assert(mat.cols % TILE_SIZE[0] == 0 && mat.rows % TILE_SIZE[1] == 0); + cv::Mat1b cn; + for (int y = 0; y + TILE_SIZE[1] <= mat.rows; y += TILE_SIZE[1]) for (int x = 0; x + TILE_SIZE[0] <= mat.cols; x += TILE_SIZE[0]) { cv::Rect roi { x, y, TILE_SIZE[0], TILE_SIZE[1] }; - auto frame = add_frame(mat(roi)); - ret.push_back(frame); + const auto m = mat(roi); + cv::extractChannel(m, cn, 3); + if (cv::countNonZero(cn) > 0) + { + auto frame = add_frame(m); + ret.push_back(frame); + } } return ret; diff --git a/big-atlas-tool/big-atlas.hpp b/big-atlas-tool/big-atlas.hpp index 8d3f166a..b95da00f 100644 --- a/big-atlas-tool/big-atlas.hpp +++ b/big-atlas-tool/big-atlas.hpp @@ -19,7 +19,7 @@ struct big_atlas_row { struct big_atlas_builder { [[nodiscard]] std::vector<big_atlas_frame> add_atlas(const std::filesystem::path& filename); big_atlas_frame& add_frame(const cv::Mat4b& frame); - constexpr Magnum::Vector2i size() const { return {maxy, maxx}; } + constexpr Magnum::Vector2i size() const { return {maxx, maxy}; } const std::vector<big_atlas_row>& rows() const { return _rows; } private: @@ -28,7 +28,7 @@ private: int ypos = 0, maxx = 0, maxy = 0; static constexpr Magnum::Vector2i TILE_SIZE = { 100, 100 }, - MAX_TEXTURE_SIZE = { 500, 500 }; + MAX_TEXTURE_SIZE = { 8192, 8192 }; static_assert(!!TILE_SIZE[0] && !!TILE_SIZE[1] && !!MAX_TEXTURE_SIZE[0] && !!MAX_TEXTURE_SIZE[1]); static_assert(MAX_TEXTURE_SIZE[0] >= TILE_SIZE[0] && MAX_TEXTURE_SIZE[1] >= TILE_SIZE[1]); |