Commit c2b2904e authored by plgruener's avatar plgruener

add threshold parameter

parent c9e8835f
#include "compute.hpp"
float compute(float alpha, float beta, aligned_vector<float> seed_x,
aligned_vector<float> seed_y, int num_iterations) {
aligned_vector<float> seed_y, int num_iterations, float threshold) {
int num_seeds = seed_x.size();
assert(seed_y.size() == num_seeds);
......@@ -13,7 +13,7 @@ float compute(float alpha, float beta, aligned_vector<float> seed_x,
float d = 0.0;
for (int i = 0; i < num_iterations && d < 1; i++) {
for (int i = 0; i < num_iterations && d < threshold ; i++) {
#pragma omp simd aligned(xp, yp : 64)
for (int s = 0; s < num_seeds; s++) {
yp[s] = yp[s] + beta * std::sin(TWO_PI * xp[s]);
......
......@@ -14,5 +14,5 @@ constexpr float PI = 3.141592635;
constexpr float TWO_PI = 6.28318530718; // 2 * PI;
float compute(float alpha, float beta, aligned_vector<float> seed_x,
aligned_vector<float> seed_y, int num_iterations);
aligned_vector<float> seed_y, int num_iterations, float threshold);
#endif
......@@ -19,6 +19,7 @@ int main(int argc, char* argv[]) {
// get arguments from CLI
// these can be input by user
int num_iterations;
float threshold;
float alphamin;
float alphamax;
int alpha_num_intervals;
......@@ -32,6 +33,7 @@ int main(int argc, char* argv[]) {
desc.add_options()
("help", "Help message")
("iterations,n", po::value<int>(&num_iterations)->default_value(100), "Number of iterations")
("threshold,s", po::value<float>(&threshold)->default_value(1), " Threshold above that computation is stopped")
("amin,a", po::value<float>(&alphamin)->default_value(0), " α lower bound")
("amax,A", po::value<float>(&alphamax)->default_value(1), " α upper bound")
("alphas,w", po::value<int>(&alpha_num_intervals)->default_value(100), "α resolution/width of image")
......@@ -114,15 +116,15 @@ int main(int argc, char* argv[]) {
// transform floats into grayscale-colors:
for (int i = 0; i < alpha_num_params*beta_num_params; ++i) {
if (buffer[i] > 1) {
if (result[i] > threshold) {
colors[i] = 255;
colors_rgb[3*i] = 255;
colors_rgb[3*i+1] = 255;
colors_rgb[3*i+2] = 255;
} else {
colors[i] = (int) 254 * buffer[i];
colors[i] = (int) 254 * result[i]/threshold;
// RGB color gradient: viridis from matplotlib
int idx = floor(buffer[i]*255);
int idx = floor(255*result[i]/threshold);
int r = floor(255*viridis[idx][0]);
int g = floor(255*viridis[idx][1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment