-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename io fodler to export folder, add import array fro file using Op…
…enCV imread
- Loading branch information
Showing
13 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General | ||
* Public License. The full license is in the file LICENSE, distributed with | ||
* this software. */ | ||
#include "macrologger.h" | ||
|
||
#include "highmap/array.hpp" | ||
|
||
namespace hmap | ||
{ | ||
|
||
Array read_to_array(std::string fname) | ||
{ | ||
cv::Mat mat = cv::imread(fname, cv::IMREAD_GRAYSCALE); | ||
|
||
if (mat.data == nullptr) | ||
{ | ||
LOG_ERROR("error while reading the image file: %s", fname.c_str()); | ||
return Array(); | ||
} | ||
else | ||
{ | ||
cv::rotate(mat, mat, cv::ROTATE_90_CLOCKWISE); | ||
bool remap = true; | ||
return cv_mat_to_array(mat, remap); | ||
} | ||
} | ||
|
||
} // namespace hmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(ex_read_to_array ex_read_to_array.cpp) | ||
target_link_libraries(ex_read_to_array highmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "highmap.hpp" | ||
|
||
int main(void) | ||
{ | ||
hmap::Vec2<int> shape = {256, 128}; | ||
hmap::Vec2<float> res = {4.f, 2.f}; | ||
int seed = 1; | ||
|
||
hmap::Array z0 = hmap::noise_fbm(hmap::NoiseType::PERLIN, shape, res, seed); | ||
hmap::remap(z0, 0.f, 1.f); | ||
|
||
z0.to_png("out1.png", hmap::Cmap::GRAY); // grayscale | ||
z0.to_png("out2.png", hmap::Cmap::JET); // RGB image | ||
|
||
hmap::Array z1 = hmap::read_to_array("out1.png"); | ||
hmap::Array z2 = hmap::read_to_array("out2.png"); // converted to grayscale | ||
|
||
hmap::export_banner_png("ex_read_to_array.png", | ||
{z0, z1, z2}, | ||
hmap::Cmap::INFERNO); | ||
} |