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 SINEWAVE (
00014 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 ) { register short j, k;
00021     char   msg[SLEN];
00022     double factor;
00023 
00024     if (TIMES) TIMING(T_SINEWAVE);
00025     if (NAMES) {
00026         MESSAGE('I',"");
00027         MESSAGE('I',"SINEWAVE");
00028         MESSAGE('I',"");
00029         sprintf(msg," Image size: lines:    %d",nlin);
00030         MESSAGE('I',msg);
00031         sprintf(msg,"             pixels:   %d",npix);
00032         MESSAGE('I',msg);
00033         sprintf(msg," Period:             %12.4e",period);
00034         MESSAGE('I',msg);
00035         sprintf(msg," Phase:              %12.4e",phase);
00036         MESSAGE('I',msg);
00037         MESSAGE('I'," ...............");
00038     }
00039 
00040     /* check input */
00041     if (nlin <= 0) {
00042         MESSAGE('E'," Number of lines must be greater than zero.");
00043         goto the_end;
00044     } else if (npix <= 0) {
00045         MESSAGE('E'," Number of pixels/line must be greater than zero.");
00046         goto the_end;
00047     } else if (period <= 0.0) {
00048         MESSAGE('E'," Period must be greater than zero.");
00049         goto the_end;
00050     }
00051 
00052     /* create image of appropriate size */
00053     if (!CHECKIMG(*out)) GETMEM(1,nlin,npix,out);
00054     if (!*out) goto the_end;
00055 
00056     /* create sinewave pattern */
00057     factor = 2.0*PI/period;
00058     phase *= factor;
00059     for (k=0; k<npix; k++) {
00060         (*out)->data[0][0][k] = (PIXEL)((double)(SMAX-SMIN)*(0.5*sin(factor*(double)k+phase)+0.5)+(double)SMIN);
00061     }
00062     for (j=0; j<nlin; j++) {
00063         for (k=0; k<npix; k++) {
00064             (*out)->data[0][j][k] = (*out)->data[0][0][k];
00065         }
00066     }
00067     
00068     the_end:
00069     if (TIMES)  TIMING(T_EXIT);
00070 }

Generated on Wed Apr 9 08:56:14 2003 for TREES by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002