Created
February 27, 2016 05:25
-
-
Save golanlevin/06236460f8ff1d97a3dd to your computer and use it in GitHub Desktop.
Processing program for histogram matching (work in progress)
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
float ideal[] = { | |
0.092, | |
0.518, | |
0.846, | |
1.000, | |
0.960, | |
0.850, | |
0.740, | |
0.640, | |
0.550, | |
0.456, | |
0.378, | |
0.300, | |
0.222, | |
0.144, | |
0.086, | |
0.034, | |
0.008 | |
}; | |
void setup() { | |
size(1000, 500); | |
} | |
void draw() { | |
background(255); | |
println(ideal.length); | |
noFill(); | |
float cumulative = 0; | |
for (int i=0; i<1000; i++){ | |
float t = map(i, 0,1000, 0,ideal.length-1); | |
t = constrain(t, 0,ideal.length-1); | |
float index1 = floor(t); | |
float index2 = ceil(t); | |
float index0 = max(0, index1 - 1); | |
float index3 = min(ideal.length-1, index2 + 1); | |
float frac = t - index1; | |
float val0 = ideal[(int)index0]; | |
float val1 = ideal[(int)index1]; | |
float val2 = ideal[(int)index2]; | |
float val3 = ideal[(int)index3]; | |
float valt = curvePoint(val0, val1, val2, val3, frac); | |
float x = i; | |
float y = valt * 200 * 0.990; | |
stroke(0); | |
line (x, 200, x, 200-y); | |
float b = 557.0; | |
float c = 65.0; | |
float d = 60.0; | |
float valg = exp(0 - (sq(100*log(x+d)-b))/(2.0*c*c)); | |
float gy = 199 * valg; | |
stroke(0,180,0, 180); | |
ellipse(x,200-gy, 2,2); | |
cumulative += valg; //valt; | |
float cumy = cumulative; | |
stroke(255,0,0, 127); | |
line (x, 500, x, 500 - cumy); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment