diff options
-rw-r--r-- | jinc.c | 56 |
1 files changed, 46 insertions, 10 deletions
@@ -17,7 +17,7 @@ static const double J1_roots[] = }; #define MAIN_LOBE (J1_roots[0] / M_PI) -#define LOBES (J1_roots[2] / M_PI) +#define LOBES (J1_roots[4] / M_PI) #define AT_ZERO (M_PI / 4) static double @@ -44,7 +44,7 @@ jinc_jinc (double x, double y) return rf; } -#define SIZE 512 +#define SIZE 1024 static complex_image_t * make_jinc_image (void) @@ -70,7 +70,7 @@ make_jinc_image (void) r->re = g->re = b->re = 0.0; r->re = v; - b->re = 1 - v; + b->re = 0; r->im = g->im = b->im = 0.0; } @@ -186,16 +186,51 @@ make_jnw_image (void) double step = (2 * LOBES) / (double)SIZE; double x = - LOBES + step / 2 + i * step; double y = - LOBES + step / 2 + j * step; - double v; + double vj, vs; - v = jinc (sqrt (8 * x * 8 * x + 8 * y * 8 * y)); + vj = (jinc (sqrt (8 * x * 8 * x + 8 * y * 8 * y))); + vs = (sinc (8 * x) * sinc (8 * y)); - v = 0.5 * (v + 1); - + r->re = g->re = b->re = 0.0; + r->re = 0.5 * (vj + 1); + g->re = 0.0; // 0.5 * (vs + 1); + b->re = 0.0; + + r->im = g->im = b->im = 0.0; + } + } + + return result; +} + +static complex_image_t * +make_box_image (void) +{ + complex_image_t *result = complex_image_new (SIZE, SIZE); + int i, j; + + for (j = 0; j < SIZE; ++j) + { + for (i = 0; i < SIZE; ++i) + { + complex_t *r = &(result->red[j * SIZE + i]); + complex_t *g = &(result->green[j * SIZE + i]); + complex_t *b = &(result->blue[j * SIZE + i]); + double step = (2 * 0.5) / (double)SIZE; + double x = - 0.5 + step / 2 + i * step; + double y = - 0.5 + step / 2 + j * step; + double v; + + if (fabs (8 * x) < 0.5 && fabs (8 * y) < 0.5) + v = 1; + else + v = 0; + + r->re = g->re = b->re = 0.0; b->re = v; - g->re = 1 - v; - r->re = v; + g->re = 0.0; // 0.5 * (vs + 1); + r->re = 0.0; r->im = g->im = b->im = 0.0; } @@ -204,6 +239,7 @@ make_jnw_image (void) return result; } + static complex_t filter (complex_t c, double dist) { @@ -246,7 +282,7 @@ main (int argc, char **argv) g_type_init (); - image = make_jnw_image (); + image = make_lanczos_image (); g_print ("width, height %d %d\n", image->width, image->height); |