aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roots.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/roots.cpp b/roots.cpp
index 25102ba..0ba8fe9 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -4,6 +4,7 @@
#include <tuple>
#include <functional>
#include <thread>
+#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdint>
@@ -316,9 +317,10 @@ tuple<int*,int,int> readData(const char *fname){
inline double interpCurve(double x){
// return atan(30*x);
- return pow(x,1.0/2);
+ // return pow(x,1.0/2);
// return sqrt(log(18*pow(x,0.7)+1));
// return x;
+ return log(x+1);
}
inline double interp(double x,double clip){
@@ -328,12 +330,22 @@ inline double interp(double x,double clip){
void buildImage(unsigned char *image,const int *tally,int width,int height){
int maxval=0;
for(int i=0;i<width*height;i++){
- maxval=max(maxval,(int)tally[i]);
+ maxval=max(maxval,tally[i]);
}
+
+ int cumul[maxval+1];
+ memset(cumul,0,(maxval+1)*sizeof(int));
+ for(int i=0;i<width*height;i++){
+ cumul[tally[i]]++;
+ }
+ for(int i=1;i<maxval+1;i++){
+ cumul[i]+=cumul[i-1];
+ }
+ assert(cumul[maxval]==width*height);
+
for(int i=0;i<width*height;i++){
- // image[3*i+0]=interp((double)min(tally[i],300)/300,0.4)*255;
- image[3*i+0]=interp((double)min(tally[i],40)/40,0.4)*255;
- // image[3*i+0]=interp((double)tally[i],0.4)*255;
+ // image[3*i+0]=interp((double)min(tally[i],capval)/capval,0.4)*255;
+ image[3*i]=pow((double)cumul[tally[i]]/cumul[maxval],2)*255;
image[3*i+1]=image[3*i+0];
image[3*i+2]=image[3*i+0];
}