~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/covira/imwrinkle.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * sphere.c
  3  *
  4  * @(#)Make test images
  5  *
  6  */
  7 
  8 #include <stdio.h>
  9 #include <math.h>
 10 #include <string.h>
 11 #include <tina/sys.h>
 12 #include <tina/sysfuncs.h>
 13 #include <tina/math.h>
 14 #include <tina/mathfuncs.h>
 15 #include <tina/vision.h>
 16 #include <tina/visionfuncs.h>
 17 #include <tina/file.h>
 18 #include <tina/filefuncs.h>
 19 
 20 static Imrect *im_wrinkle(int width, int height,
 21     double cx, double cy,
 22     double r, double a, int n, double theta, int low, int high)
 23 {
 24     int *row;
 25     Imrect *im = im_alloc(height, width, NULL, uchar_v);
 26     int x, y;
 27     double c = cos(theta), s = sin(theta);
 28 
 29     row = tvector_alloc(0, width, int);
 30     for (y = 0; y < height; y++)
 31     {
 32         for (x = 0; x < width; x++)
 33         {
 34             double x1, x2, y1, y2;
 35             double phi;
 36             x1 = x-cx;
 37             y1 = y-cy;
 38             x2 =  c*x1+s*y1;
 39             y2 = -s*x1+c*y1;
 40             phi = atan2(y2, x2);
 41             if (sqrt(x2 * x2 + y2 * y2) > r+a*cos(n*phi))
 42                 row[x] = low;
 43             else
 44                 row[x] = high;
 45         }
 46         im_put_row(row, im, y, 0, width);
 47     }
 48     tvector_free(row, 0, int);
 49     return (im);
 50 }
 51 
 52 main(void)
 53 {
 54     char filename[32];
 55     int i, n = 32;
 56     double dphase = PIBY2/(n-1);
 57     double r0 = 10.0, r1 = 48.0;
 58     double dr = (r1-r0)/(n-1);
 59     for (i = 0; i < n; i++)
 60     {
 61         Imrect *im1, *im2, *im3;
 62         double phase = i*dphase;
 63         double r = r0+i*dr;
 64         im1 = imf_unif_noise(128, 128, 1, 1, 150.0, 200.0);
 65         im2 = im_wrinkle(128, 128, 64.0, 64.0, r, 0.25*r, 8, phase, 0, 55);
 66         im3 = imf_sum(im1, im2); im_free(im1); im_free(im2);
 67         im1 = im_cast(im3, uchar_v); im_free(im3);
 68         sprintf(filename, "wrinkle.%d", i);
 69         raw_write_image(im1, filename);
 70     }
 71 }
 72 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.