|
@ -4,6 +4,7 @@ |
|
|
#include <memory> |
|
|
#include <memory> |
|
|
#include <vector> |
|
|
#include <vector> |
|
|
#include <cassert> |
|
|
#include <cassert> |
|
|
|
|
|
#include <array> |
|
|
|
|
|
|
|
|
#include <png++/png.hpp> |
|
|
#include <png++/png.hpp> |
|
|
|
|
|
|
|
@ -26,6 +27,7 @@ public: |
|
|
|
|
|
|
|
|
//int_array = std::make_shared<vstd::vector<unsigned int>>(width*height*num_colors);
|
|
|
//int_array = std::make_shared<vstd::vector<unsigned int>>(width*height*num_colors);
|
|
|
int_array = new unsigned int[width*height*num_colors]; |
|
|
int_array = new unsigned int[width*height*num_colors]; |
|
|
|
|
|
LogInfo("PNG::PNG(): width: %d, height: %d, colors: %d\n", width, height, num_colors); |
|
|
|
|
|
|
|
|
assert(int_array != nullptr); |
|
|
assert(int_array != nullptr); |
|
|
|
|
|
|
|
@ -38,7 +40,7 @@ public: |
|
|
std::fill_n(int_array, width*height*num_colors, 0); |
|
|
std::fill_n(int_array, width*height*num_colors, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
virtual void plot(const double* normalizedPosition) { |
|
|
virtual void plot(const double* normalizedPosition, const double* normalizedColor) { |
|
|
const double& x = normalizedPosition[0]; |
|
|
const double& x = normalizedPosition[0]; |
|
|
const double& y = normalizedPosition[1]; |
|
|
const double& y = normalizedPosition[1]; |
|
|
|
|
|
|
|
@ -47,7 +49,11 @@ public: |
|
|
const unsigned int index = x_int + width * y_int; |
|
|
const unsigned int index = x_int + width * y_int; |
|
|
|
|
|
|
|
|
if(x_int < width && y_int < height) { |
|
|
if(x_int < width && y_int < height) { |
|
|
int_array[index]++; |
|
|
if(normalizedColor[0] > 0.0){ |
|
|
|
|
|
int_array[index]++; |
|
|
|
|
|
} else { |
|
|
|
|
|
int_array[index + width*height]++; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -57,7 +63,7 @@ public: |
|
|
unsigned int* max_int = new unsigned int[num_colors]; |
|
|
unsigned int* max_int = new unsigned int[num_colors]; |
|
|
double* power = new double[num_colors]; |
|
|
double* power = new double[num_colors]; |
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < num_colors; i++) { |
|
|
for(unsigned int i = 0; i < num_colors; ++i) { |
|
|
max_int[i] = 0; |
|
|
max_int[i] = 0; |
|
|
double cumulative = 0; |
|
|
double cumulative = 0; |
|
|
unsigned int n = 0; |
|
|
unsigned int n = 0; |
|
@ -80,9 +86,8 @@ public: |
|
|
LogInfo("negative power\n"); |
|
|
LogInfo("negative power\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(n < width) { |
|
|
if(n < width) { |
|
|
LogInfo("not enough data\n"); |
|
|
LogInfo("not enough data in dimension %d\n", i); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -102,6 +107,16 @@ public: |
|
|
// pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
|
|
// pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
|
|
|
|
|
|
|
|
png::image< png::rgb_pixel > image(width, height); |
|
|
png::image< png::rgb_pixel > image(width, height); |
|
|
|
|
|
std::array<double, 6> power_matrix = {{ |
|
|
|
|
|
1.0, 1.5, |
|
|
|
|
|
2.0, 2.5, |
|
|
|
|
|
3.0, 1.5 |
|
|
|
|
|
}}; |
|
|
|
|
|
std::array<double, 6> output_matrix = {{ |
|
|
|
|
|
2.0, 2.0, |
|
|
|
|
|
2.0, 1.5, |
|
|
|
|
|
2.0, 2.0 |
|
|
|
|
|
}}; |
|
|
|
|
|
|
|
|
for(unsigned int x = 0; x < width; x++) { |
|
|
for(unsigned int x = 0; x < width; x++) { |
|
|
for(unsigned int y = 0; y < height; y++) { |
|
|
for(unsigned int y = 0; y < height; y++) { |
|
@ -110,22 +125,9 @@ public: |
|
|
double b = 0.0; |
|
|
double b = 0.0; |
|
|
for(unsigned int c = 0; c < num_colors; c++) { |
|
|
for(unsigned int c = 0; c < num_colors; c++) { |
|
|
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c]; |
|
|
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c]; |
|
|
switch(c) { |
|
|
r += (pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0]; |
|
|
case 0: { |
|
|
g += (pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2]; |
|
|
r = (pow(norm_value, power[c]))*3.0; |
|
|
b += (pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4]; |
|
|
//break;
|
|
|
|
|
|
} |
|
|
|
|
|
case 1: { |
|
|
|
|
|
g = (pow(norm_value, power[c]*2.0))*3.0; |
|
|
|
|
|
//break;
|
|
|
|
|
|
} |
|
|
|
|
|
case 2: { |
|
|
|
|
|
b = (pow(norm_value, power[c]*3.0))*3.0; |
|
|
|
|
|
//break;
|
|
|
|
|
|
} |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
// TODO: also clamp is below 0 ?
|
|
|
// TODO: also clamp is below 0 ?
|
|
|
r = std::min(1.0, r); |
|
|
r = std::min(1.0, r); |
|
|