Warning: session_start(): open(/var/lib/php/sessions/sess_5e6cjq4tsbi6v86ilsfhle3org, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass Gazelle22_GradientImage {
BWImage posterized;
BWImage out;
PosterizeBWImage op;
BWImage unposterized;
BWImage get() {
op = cast getMetaSrc(posterized);
unposterized = op.img;
brightnessLevels = op.brightnessLevels;
assertSameSize(unposterized, posterized);
int w = posterized.getWidth(), h = posterized.getHeight();
out = new(w*2+1, h*2+1);
int singleStep = iceil(doubleRatio(255, brightnessLevels-1));
for y to h:
for x to w: {
if (x < w-1) checkPair(x, y, x+1, y);
if (y < h-1) checkPair(x, y, x, y+1);
}
ret out;
}
void checkPair(int x, int y, int x2, int y2) {
int posterizedContrast = absDiff(posterized.getInt(x, y),
posterized.getInt(x+1, y));
if (posterizedContrast == 0) ret;
if (posterizedContrast > singleStep) ret;
int realContrast = absDiff(unposterized.getInt(x, y),
unposterized.getInt(x+1, y));
double ratio = doubleRatio(realContrast, singleStep);
if (ratio < .5) {
float result = 1f;
out.setPixel(x*2+1-(x2-x), y*2+1, result);
out.setPixel(x*2+1, y*2+1-(y2-y), result);
}
}
}