 Timestamp:
 Mar 24, 2009, 1:48:53 AM (12 years ago)
 Location:
 libpipi/trunk/pipi
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

libpipi/trunk/pipi/context.c
r3397 r3410 779 779 char const *arg; 780 780 va_list ap; 781 float freq, phase, theta, ampx, ampy;781 float dw, dh, d = 0.0, a = 0.0; 782 782 int ret; 783 783 … … 789 789 va_end(ap); 790 790 791 ret = sscanf(arg, "%g,%g,%g,%gx%g", 792 &freq, &phase, &theta, &x, &y); 793 if(ret < 5) 794 return 1; 795 796 tmp = ctx>images[ctx>nimages  1]; 797 ctx>images[ctx>nimages  1] = pipi_wave(tmp, freq, phase, 798 theta, ampx, ampy); 791 ret = sscanf(arg, "%gx%g+%gr%g", &dw, &dh, &d, &a); 792 if(ret < 2) 793 return 1; 794 795 tmp = ctx>images[ctx>nimages  1]; 796 ctx>images[ctx>nimages  1] = pipi_wave(tmp, dw, dh, d, a); 799 797 pipi_free(tmp); 800 798 } 
libpipi/trunk/pipi/filter/wave.c
r3403 r3410 27 27 #include "pipi_internals.h" 28 28 29 pipi_image_t *pipi_wave(pipi_image_t *src, double freq, double phase, 30 double theta, double xamp, double yamp) 29 #define BORDER 64 30 31 pipi_image_t *pipi_wave(pipi_image_t *src, double dw, double dh, 32 double d, double a) 31 33 { 32 34 pipi_image_t *dst; 33 35 pipi_pixels_t *srcp, *dstp; 34 36 float *srcdata, *dstdata; 35 double sin t, cost;37 double sina, cosa; 36 38 int x, y, w, h, i, gray; 37 39 … … 50 52 dstdata = (float *)dstp>pixels; 51 53 52 sin t = sin(theta);53 cos t = cos(theta);54 sina = sin(a); 55 cosa = cos(a); 54 56 55 57 for(y = 0; y < h; y++) … … 57 59 for(x = 0; x < w; x++) 58 60 { 59 double t = cost * (x  w / 2) + sint * (y  h / 2);60 double step = sin(t * freq + phase);61 double d x = xamp;62 double d y = yamp;61 double angle = 2 * M_PI / dw * ((x  w / 2) * cosa 62 + (y  h / 2) * sina  d); 63 double displacement = dh * sin(angle); 64 double dx, dy; 63 65 int x2, y2; 64 66 65 if(x < 32) dx = dx * x / 32; 66 if(x > w  1  32) dx = dx * (w  1  x) / 32; 67 if(y < 32) dy = dy * y / 32; 68 if(y > h  1  32) dy = dy * (h  1  y) / 32; 67 dx = sina * displacement; 68 dy = cosa * displacement; 69 69 70 x2 = x + dx * step; 71 y2 = y + dy * step; 70 if(x < BORDER) dx = dx * x / BORDER; 71 if(x > w  1  BORDER) dx = dx * (w  1  x) / BORDER; 72 if(y < BORDER) dy = dy * y / BORDER; 73 if(y > h  1  BORDER) dy = dy * (h  1  y) / BORDER; 74 75 x2 = x + dx; 76 y2 = y + dy; 72 77 73 78 /* Just in case... */ 
libpipi/trunk/pipi/pipi.h
r3397 r3410 199 199 __extern pipi_image_t *pipi_erode(pipi_image_t *); 200 200 __extern pipi_image_t *pipi_wave(pipi_image_t *, double, double, 201 double, double , double);201 double, double); 202 202 203 203 __extern pipi_image_t *pipi_order(pipi_image_t *);
Note: See TracChangeset
for help on using the changeset viewer.