Main Page   Data Structures   File List   Data Fields   Globals  

sinewave.c

Go to the documentation of this file.
00001 #include        "sadie.h"
00002 
00003 /*-Copyright Information------------------------------------------------------*/
00004 /* Copyright (c) 1988 by the University of Arizona Digital Image Analysis Lab */
00005 /*----------------------------------------------------------------------------*/
00006 /*-General Information--------------------------------------------------------*/
00007 /*                                                                            */
00008 /*   This function generates a sinewave pattern in the x-direction.           */
00009 /*   The minimum graylevel is SMIN, and the maximum graylevel is SMAX.        */
00010 /*                                                                            */
00011 /*----------------------------------------------------------------------------*/
00012 /*-Interface Information------------------------------------------------------*/
00013 void
00014 SINEWAVE (short nlin,           /*  I   Number of lines.                                      */
00015           short npix,           /*  I   Number of pixels/line.                                */
00016           double period,        /*  I   Period of the sinewave in pixels.                     */
00017           double phase,         /*  I   Phase of the sinewave in pixels.                      */
00018           IMAGE ** out          /*  O   Address of a pointer to the output image.             */
00019 /*----------------------------------------------------------------------------*/
00020   )
00021 {
00022   register short j, k;
00023   char msg[SLEN];
00024   double factor;
00025 
00026   if (TIMES)
00027     TIMING (T_SINEWAVE);
00028   if (NAMES)
00029     {
00030       MESSAGE ('I', "");
00031       MESSAGE ('I', "SINEWAVE");
00032       MESSAGE ('I', "");
00033       sprintf (msg, " Image size: lines:    %d", nlin);
00034       MESSAGE ('I', msg);
00035       sprintf (msg, "             pixels:   %d", npix);
00036       MESSAGE ('I', msg);
00037       sprintf (msg, " Period:             %12.4e", period);
00038       MESSAGE ('I', msg);
00039       sprintf (msg, " Phase:              %12.4e", phase);
00040       MESSAGE ('I', msg);
00041       MESSAGE ('I', " ...............");
00042     }
00043 
00044   /* check input */
00045   if (nlin <= 0)
00046     {
00047       MESSAGE ('E', " Number of lines must be greater than zero.");
00048       goto the_end;
00049     }
00050   else if (npix <= 0)
00051     {
00052       MESSAGE ('E', " Number of pixels/line must be greater than zero.");
00053       goto the_end;
00054     }
00055   else if (period <= 0.0)
00056     {
00057       MESSAGE ('E', " Period must be greater than zero.");
00058       goto the_end;
00059     }
00060 
00061   /* create image of appropriate size */
00062   if (!CHECKIMG (*out))
00063     GETMEM (1, nlin, npix, out);
00064   if (!*out)
00065     goto the_end;
00066 
00067   /* create sinewave pattern */
00068   factor = 2.0 * PI / period;
00069   phase *= factor;
00070   for (k = 0; k < npix; k++)
00071     {
00072       (*out)->data[0][0][k] =
00073         (PIXEL) ((double) (SMAX - SMIN) *
00074                  (0.5 * sin (factor * (double) k + phase) + 0.5) +
00075                  (double) SMIN);
00076     }
00077   for (j = 0; j < nlin; j++)
00078     {
00079       for (k = 0; k < npix; k++)
00080         {
00081           (*out)->data[0][j][k] = (*out)->data[0][0][k];
00082         }
00083     }
00084 
00085 the_end:
00086   if (TIMES)
00087     TIMING (T_EXIT);
00088 }

Generated on Sun May 18 15:36:18 2003 for tclSadie by doxygen1.3