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 CHECKER (
00016 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 ) { register short j, k;
00023     char msg[SLEN];
00024 
00025     if (TIMES) TIMING(T_CHECKER);
00026     if (NAMES) {
00027         MESSAGE('I',"");
00028         MESSAGE('I',"CHECKER");
00029         MESSAGE('I',"");
00030         sprintf(msg," Image size: lines:    %d",nlin);
00031         MESSAGE('I',msg);
00032         sprintf(msg,"             pixels:   %d",npix);
00033         MESSAGE('I',msg);
00034         sprintf(msg," Check size: lines:    %d",jsize);
00035         MESSAGE('I',msg);
00036         sprintf(msg,"             pixels:   %d",ksize);
00037         MESSAGE('I',msg);
00038         MESSAGE('I'," ...............");
00039     }
00040 
00041     /* check input */
00042     if (nlin <= 0) {
00043         MESSAGE('E'," Number of lines must be greater than zero.");
00044         goto the_end;
00045     } else if (npix <= 0) {
00046         MESSAGE('E'," Number of pixels/line must be greater than zero.");
00047         goto the_end;
00048     } else if (jsize <= 0) {
00049         MESSAGE('E'," Size of square in lines must be greater than zero.");
00050         goto the_end;
00051     } else if (jsize > nlin) {
00052         MESSAGE('E'," Size of square in lines must be less than or equal to the number of lines.");
00053         goto the_end;
00054     } else if (ksize <= 0) {
00055         MESSAGE('E'," Size of square in pixels/line must be greater than zero.");
00056         goto the_end;
00057     } else if (ksize > npix) {
00058         MESSAGE('E'," Size of square in pixels/line must be less than or equal to the number of pixels/line.");
00059         goto the_end;
00060     }
00061 
00062     /* create image of appropriate size */
00063     if (!CHECKIMG(*out)) GETMEM(1,nlin,npix,out);
00064     if (!*out) goto the_end;
00065 
00066     /* create checkerboard pattern */
00067     for (j=0; j<nlin; j++) {
00068         for (k=0; k<npix; k++) {
00069             (*out)->data[0][j][k] = (PIXEL)((j/jsize+k/ksize)%2 == 0  ?  SMIN : SMAX);
00070         }
00071     }
00072     (*out)->gmin = (PIXEL)SMIN;
00073     (*out)->gmax = (PIXEL)SMAX;
00074     
00075     the_end:
00076     if (TIMES) TIMING(T_EXIT);
00077 }

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