Main Page   Data Structures   File List   Data Fields   Globals  

checker.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 binary checkerboard pattern. The graylevel     */
00009 /*   of the check in the upper left corner is SMIN, and the remaining         */
00010 /*   checks alternate between SMAX and SMIN. Appropriate parameters will      */
00011 /*   generate a binary bar pattern.                                           */
00012 /*                                                                            */
00013 /*----------------------------------------------------------------------------*/
00014 /*-Interface Information------------------------------------------------------*/
00015 void
00016 CHECKER (short nlin,            /*  I   Number of lines.                                      */
00017          short npix,            /*  I   Number of pixels/line.                                */
00018          short jsize,           /*  I   Number of lines per check.                            */
00019          short ksize,           /*  I   Number of pixels/line per check.                      */
00020          IMAGE ** out           /*  O   Address of a pointer to the output image.             */
00021 /*----------------------------------------------------------------------------*/
00022   )
00023 {
00024   register short j, k;
00025   char msg[SLEN];
00026 
00027   if (TIMES)
00028     TIMING (T_CHECKER);
00029   if (NAMES)
00030     {
00031       MESSAGE ('I', "");
00032       MESSAGE ('I', "CHECKER");
00033       MESSAGE ('I', "");
00034       sprintf (msg, " Image size: lines:    %d", nlin);
00035       MESSAGE ('I', msg);
00036       sprintf (msg, "             pixels:   %d", npix);
00037       MESSAGE ('I', msg);
00038       sprintf (msg, " Check size: lines:    %d", jsize);
00039       MESSAGE ('I', msg);
00040       sprintf (msg, "             pixels:   %d", ksize);
00041       MESSAGE ('I', msg);
00042       MESSAGE ('I', " ...............");
00043     }
00044 
00045   /* check input */
00046   if (nlin <= 0)
00047     {
00048       MESSAGE ('E', " Number of lines must be greater than zero.");
00049       goto the_end;
00050     }
00051   else if (npix <= 0)
00052     {
00053       MESSAGE ('E', " Number of pixels/line must be greater than zero.");
00054       goto the_end;
00055     }
00056   else if (jsize <= 0)
00057     {
00058       MESSAGE ('E', " Size of square in lines must be greater than zero.");
00059       goto the_end;
00060     }
00061   else if (jsize > nlin)
00062     {
00063       MESSAGE ('E',
00064                " Size of square in lines must be less than or equal to the number of lines.");
00065       goto the_end;
00066     }
00067   else if (ksize <= 0)
00068     {
00069       MESSAGE ('E',
00070                " Size of square in pixels/line must be greater than zero.");
00071       goto the_end;
00072     }
00073   else if (ksize > npix)
00074     {
00075       MESSAGE ('E',
00076                " Size of square in pixels/line must be less than or equal to the number of pixels/line.");
00077       goto the_end;
00078     }
00079 
00080   /* create image of appropriate size */
00081   if (!CHECKIMG (*out))
00082     GETMEM (1, nlin, npix, out);
00083   if (!*out)
00084     goto the_end;
00085 
00086   /* create checkerboard pattern */
00087   for (j = 0; j < nlin; j++)
00088     {
00089       for (k = 0; k < npix; k++)
00090         {
00091           (*out)->data[0][j][k] =
00092             (PIXEL) ((j / jsize + k / ksize) % 2 == 0 ? SMIN : SMAX);
00093         }
00094     }
00095   (*out)->gmin = (PIXEL) SMIN;
00096   (*out)->gmax = (PIXEL) SMAX;
00097 
00098 the_end:
00099   if (TIMES)
00100     TIMING (T_EXIT);
00101 }

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