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

Linux Cross Reference
Tina4/src/covira/imcone.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_ellipse(int width, int height,
 21     double cx, double cy,
 22     double ax, double ay, 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 
 36             x1 = x-cx;
 37             y1 = y-cy;
 38             x2 =  c*x1+s*y1;
 39             y2 = -s*x1+c*y1;
 40             x2 /= ax;
 41             y2 /= ay;
 42 
 43             if (x2 * x2 + y2 * y2 > 1.0)
 44                 row[x] = low;
 45             else
 46                 row[x] = high;
 47         }
 48         im_put_row(row, im, y, 0, width);
 49     }
 50 
 51     tvector_free(row, 0, int);
 52     return (im);
 53 }
 54 
 55 main(void)
 56 {
 57     char filename[32];
 58     int i, n = 32;
 59     double dphase = TWOPI/(n-1);
 60     double r0 = 10.0, r1 = 60.0;
 61     double dr = (r1-r0)/(n-1);
 62     for (i = 0; i < n; i++)
 63     {
 64         Imrect *im1, *im2, *im3;
 65         double phase = i*dphase;
 66         double r = r0+i*dr;
 67         im1 = imf_unif_noise(128, 128, 1, 1, 150.0, 200.0);
 68         im2 = im_ellipse(128, 128, 64.0, 64.0, r, 0.5*r, phase, 0, 55);
 69         im3 = imf_sum(im1, im2); im_free(im1); im_free(im2);
 70         im1 = im_cast(im3, uchar_v); im_free(im3);
 71         sprintf(filename, "cone.%d", i);
 72         raw_write_image(im1, filename);
 73     }
 74 }
 75 

~ [ 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.