From 58a7d36d6105e6c31ebb75284dcef3ae54b1e270 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 15 Sep 2018 18:35:11 +0200 Subject: [PATCH] remove weighted nonsense for master branch it's not laplace! --- resynth.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/resynth.c b/resynth.c index 80e6bc9..fcefcd3 100644 --- a/resynth.c +++ b/resynth.c @@ -146,7 +146,6 @@ typedef struct { double autism; int neighbors, tries; int magic; - bool weighted; } Parameters; INLINE bool wrap_or_clip(const Parameters parameters, const Image image, @@ -233,14 +232,7 @@ static void make_offset_list(Resynth_state *s) { sizeof(Coord), coord_compare); } -INLINE int weight_at(const Coord point) { - if (point.x == 0 && point.y == 0) return 360; - // this is stable and accurate up to -N 37 (-R 9) - // 520 might work in place of 360 and provide more accuracy w/o overflows. - return 360 / (point.x * point.x + point.y * point.y); -} - -INLINE void try_point(Resynth_state *s, const Coord point, bool weighted) { +INLINE void try_point(Resynth_state *s, const Coord point) { // consider a candidate pixel for the best-fit by considering its neighbors. int sum = 0; @@ -260,7 +252,6 @@ INLINE void try_point(Resynth_state *s, const Coord point, bool weighted) { } } - if (weighted) diff *= weight_at(s->neighbors[i]); #ifdef NDEBUG sum += diff; #else @@ -408,7 +399,7 @@ static void resynth(Resynth_state *s, Parameters parameters) { // skip computing differences of points // we've already done this iteration. not mandatory. if (*image_atc(s->tried, point) == i) continue; - try_point(s, point, parameters.weighted); + try_point(s, point); *image_atc(s->tried, point) = i; } } @@ -418,7 +409,7 @@ static void resynth(Resynth_state *s, Parameters parameters) { // after that, this step is optional. it can improve subjective quality. for (int j = 0; j < parameters.tries && s->best != 0; j++) { int random = rnd_pcg_range(&pcg, 0, sb_count(s->corpus_points) - 1); - try_point(s, s->corpus_points[random], parameters.weighted); + try_point(s, s->corpus_points[random]); } // finally, copy the best pixel to the output image. @@ -475,7 +466,6 @@ int main(int argc, char *argv[]) { Parameters parameters = {0}; parameters.v_tile = true; parameters.h_tile = true; - parameters.weighted = false; // our extension // blah = our default; // original resynthesizer default parameters.magic = 192; // 192 (3/4) parameters.autism = 32. / 256.; // 30. / 256. @@ -528,15 +518,6 @@ int main(int argc, char *argv[]) { " default: 0 [time(0)]") seed = (unsigned long) kyaa_flag_arg; - KYAA_FLAG('w', "weighted", -" enables something like laplace convolution but not really\n" -" default: off") - parameters.weighted = true; - - KYAA_FLAG('W', "unweighted", -" disables --weighted") - parameters.weighted = false; - KYAA_HELP(" {files...}\n" " image files to open, resynthesize, and save as {filename}.resynth.png\n" " required default: [none]")