-
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.
Add read array from numpy file and write array to numpy file
- Loading branch information
Showing
10 changed files
with
113 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
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
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
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
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_from_numpy ex_from_numpy.cpp) | ||
target_link_libraries(ex_from_numpy 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,19 @@ | ||
#include <iostream> | ||
|
||
#include "highmap.hpp" | ||
|
||
int main(void) | ||
{ | ||
hmap::Vec2<int> shape = {512, 256}; | ||
hmap::Vec2<float> res = {4.f, 2.f}; | ||
int seed = 1; | ||
|
||
hmap::Array z1 = hmap::noise_fbm(hmap::NoiseType::PERLIN, shape, res, seed); | ||
|
||
z1.to_numpy("out.npy"); | ||
|
||
hmap::Array z2; | ||
z2.from_numpy("out.npy"); | ||
|
||
hmap::export_banner_png("ex_from_numpy.png", {z1, z2}, hmap::cmap::inferno); | ||
} |
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_to_numpy ex_to_numpy.cpp) | ||
target_link_libraries(ex_to_numpy 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,24 @@ | ||
#include <iostream> | ||
|
||
#include "highmap.hpp" | ||
|
||
int main(void) | ||
{ | ||
hmap::Vec2<int> shape = {512, 256}; | ||
hmap::Vec2<float> res = {4.f, 2.f}; | ||
int seed = 1; | ||
|
||
hmap::Array z = hmap::noise_fbm(hmap::NoiseType::PERLIN, shape, res, seed); | ||
|
||
std::cout << z(10, 12) << std::endl; | ||
|
||
z.to_numpy("out.npy"); | ||
z.to_png("ex_to_numpy.png", hmap::cmap::jet); | ||
|
||
// --- python script to check this | ||
|
||
// import numpy as np | ||
// z = np.load('out.npy') | ||
// print(z.shape) | ||
// print(z[10, 12]) | ||
} |
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