Browse Source

added normal noise

pull/2/head
alexge50 3 years ago
parent
commit
0ef0ebe5ea
  1. 3
      modules/modules/noise.py
  2. 20
      modules/src/images_internal.cpp

3
modules/modules/noise.py

@ -2,3 +2,6 @@ import modules.internals
def perlin_noise(source: Image, seed: int, zoom: float, z: float, octaves: int, persistence: float)->Image:
return modules.images_internal.perlin_noise(source, seed, zoom, z, octaves, persistence)
def noise(source: Image, seed: int) -> Image:
return modules.images_internal.noise(source, seed)

20
modules/src/images_internal.cpp

@ -636,6 +636,25 @@ namespace PerlinNoise
}
}
Image noise(const Image& source, long long int seed)
{
Image new_image(source.width(), source.height());
std::mt19937 engine(seed);
std::uniform_int_distribution<uint8_t> distribution;
for(int row = 0; row < static_cast<int>(source.height()); row++)
{
for (int column = 0; column < static_cast<int>(source.width()); column++)
{
uint8_t sample = distribution(engine);
new_image.setPixel(row, column, Color(sample, sample, sample));
}
}
return new_image;
}
Image discriminator_greater_than(const Image& source, long long int threshold)
{
Image new_image(source.width(), source.height());
@ -835,6 +854,7 @@ BOOST_PYTHON_MODULE(images_internal)
def("add", add);
def("multiply", multiply);
def("perlin_noise", PerlinNoise::perlin_noise);
def("noise", noise);
def("discriminator_greater_than", discriminator_greater_than);
def("discriminator_lesser_than", discriminator_lesser_than);
def("discriminator_range", discriminator_range);

Loading…
Cancel
Save