remove polish parameter

additional layers of polish yield too negligible of an effect to bother with.
tweaking the magic parameter is preferred.
This commit is contained in:
Connor Olding 2016-10-31 15:21:22 -07:00
parent 79afa91dd8
commit e5ee52ccff
2 changed files with 19 additions and 32 deletions

View File

@ -42,9 +42,6 @@ usage:
-M --tries -M --tries
random points added to candidates random points added to candidates
range: [0,65536]; default: 192 range: [0,65536]; default: 192
-p --polish
extra iterations
range: [0,9]; default: 0
-m --magic -m --magic
magic constant, affects iterations magic constant, affects iterations
range: [0,255]; default: 192 range: [0,255]; default: 192
@ -59,8 +56,7 @@ usage:
required default: [none] required default: [none]
``` ```
the `radius` and `polish` parameters should probably be the `radius` parameter should probably be removed.
properly described or removed.
### neighborhood ### neighborhood

View File

@ -132,7 +132,7 @@ typedef struct {
bool h_tile, v_tile; bool h_tile, v_tile;
double autism; double autism;
int neighbors, tries; int neighbors, tries;
int polish, magic; int magic;
} Parameters; } Parameters;
INLINE bool wrap_or_clip(const Parameters parameters, const Image image, INLINE bool wrap_or_clip(const Parameters parameters, const Image image,
@ -298,26 +298,24 @@ static void run(Resynth_state *s, Parameters parameters) {
const int data_area = sb_count(s->data_points); const int data_area = sb_count(s->data_points);
for (int p = 0; p < parameters.polish + 1; p++) { // shuffle data points in-place
for (int i = 0; i < data_area; i++) { for (int i = 0; i < data_area; i++) {
// shuffle in-place // (we could use a better random function here)
// (we could use a better random function here) int j = rand() % data_area;
int j = rand() % data_area; Coord temp = s->data_points[i];
Coord temp = s->data_points[i]; s->data_points[i] = s->data_points[j];
s->data_points[i] = s->data_points[j]; s->data_points[j] = temp;
s->data_points[j] = temp; }
}
// polishing improves pixels chosen early in the algorithm // polishing improves pixels chosen early in the algorithm
// by reconsidering them after the output image has been filled. // by reconsidering them after the output image has been filled.
// this greatly reduces the "sparklies" in the resulting image. // this greatly reduces the "sparklies" in the resulting image.
// this is achieved by appending the first n data points to the end. // this is achieved by appending the first n data points to the end.
// n is reduced exponentially by "magic" until it's less than 1. // n is reduced exponentially by "magic" until it's less than 1.
if (parameters.magic) for (int n = data_area; n > 0;) { if (parameters.magic) for (int n = data_area; n > 0;) {
n = n * parameters.magic / 256; n = n * parameters.magic / 256;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
sb_push(s->data_points, s->data_points[i]); sb_push(s->data_points, s->data_points[i]);
}
} }
} }
@ -443,7 +441,6 @@ int main(int argc, char *argv[]) {
parameters.autism = 32. / 256.; // 30. / 256. parameters.autism = 32. / 256.; // 30. / 256.
parameters.neighbors = 29; // 30 parameters.neighbors = 29; // 30
parameters.tries = 192; // 200 (or 80 in the paper) parameters.tries = 192; // 200 (or 80 in the paper)
parameters.polish = 0; // 0
int scale = 1; int scale = 1;
unsigned long seed = 0; unsigned long seed = 0;
@ -483,11 +480,6 @@ int main(int argc, char *argv[]) {
" range: [0,65536]; default: 192") " range: [0,65536]; default: 192")
parameters.tries = kyaa_flag_arg; parameters.tries = kyaa_flag_arg;
KYAA_FLAG_LONG('p', "polish",
" extra iterations\n"
" range: [0,9]; default: 0")
parameters.polish = kyaa_flag_arg;
KYAA_FLAG_LONG('m', "magic", KYAA_FLAG_LONG('m', "magic",
" magic constant, affects iterations\n" " magic constant, affects iterations\n"
" range: [0,255]; default: 192") " range: [0,255]; default: 192")
@ -514,7 +506,6 @@ int main(int argc, char *argv[]) {
exit(1); exit(1);
} }
CLAMPV(parameters.polish, 0, 9);
CLAMPV(parameters.magic, 0, 255); CLAMPV(parameters.magic, 0, 255);
CLAMPV(parameters.autism, 0., 1.); CLAMPV(parameters.autism, 0., 1.);
CLAMPV(parameters.neighbors, 0, disc00[LEN(disc00) - 1]); CLAMPV(parameters.neighbors, 0, disc00[LEN(disc00) - 1]);