Main Page   Data Structures   File List   Data Fields   Globals  

color_overlay.c

Go to the documentation of this file.
00001 #include "sadie.h"
00002 #include "proto.h"
00003 
00004 
00005 extern  PIXEL   gmin;
00006 extern  PIXEL   gmax;
00007 
00008 #define RED    0
00009 #define GREEN  1
00010 #define BLUE   2
00011 #define YELLOW 3
00012 
00013 
00014 /*----------------------------------------------------------------------------*/
00015 /*-General Information--------------------------------------------------------*/
00016 /*                                                                            */
00017 /* This function compares two edge maps.                                      */
00018 /*                                                                            */
00019 /*----------------------------------------------------------------------------*/
00020 /*-Interface Information------------------------------------------------------*/
00021 void COLOR_OVERLAY (
00022 IMAGE  *in,      /*  I   Pointer to the input grayscale image.                */
00023 IMAGE  *binimg,  /*  I   Pointer to the input binary image.                   */
00024 int    color,    /*  I   Color to use for overlay                             */
00025 IMAGE  **out     /*  O   Pointer to the output image.                         */
00026 /*----------------------------------------------------------------------------*/
00027 ) { register short i, j, k;
00028     char msg[SLEN];
00029     IMAGE *strimg, *inverseimg, *imga, *imgb;
00030     IMAGE *rgbimg[3];
00031     short int (*tf)(IMAGE*, IMAGE **);
00032 
00033 
00034     /* check input */
00035     if (!CHECKIMG(in)) {
00036         MESSAGE('E'," Can't identify grayscale image.");
00037         goto the_end;
00038     } else if (in->nbnd > 1) {
00039         MESSAGE('E'," Only using first band for grayscale image.");
00040     }
00041     if (!CHECKIMG(binimg)) {
00042         MESSAGE('E'," Can't identify binary image.");
00043         goto the_end;
00044     } else if (binimg->nbnd > 1) {
00045         MESSAGE('E'," Only using first band for binary image.");
00046     }
00047     if ((in->nlin != binimg->nlin) || (in->npix != binimg->npix)) {
00048         MESSAGE('E'," Input images must be the same size!");
00049         goto the_end;
00050     }
00051     
00052 
00053     if (NAMES) {
00054         MESSAGE('I',"");
00055         MESSAGE('I',"COLOR_OVERLAY");
00056         MESSAGE('I',"");
00057         sprintf(msg," Grayscale image:                   %s",in->text);
00058         MESSAGE('I',msg);
00059         sprintf(msg," Binary image:                      %s",binimg ->text);
00060         MESSAGE('I',msg);
00061         MESSAGE('I',"");
00062         MESSAGE('I',"");
00063         if (color == RED) {
00064             sprintf(msg," Overlay color:  red");
00065         } else if (color == BLUE) {
00066             sprintf(msg," Overlay color:  blue");
00067         } else if (color == GREEN) {
00068             sprintf(msg," Overlay color:  green");
00069         } else {
00070             sprintf(msg," Overlay color:  yellow");
00071         }
00072         MESSAGE('I',msg);
00073         MESSAGE('I'," ...............");
00074     }
00075 
00076     
00077     tf = TFSCALE;
00078     gmin = (PIXEL) 255.0;
00079     gmax = (PIXEL) 0.0;
00080     STRETCH(binimg, tf, &inverseimg);
00081 
00082     gmin = (PIXEL) 0.0;
00083     gmax = (PIXEL) 255.0;
00084     STRETCH(binimg, tf, &binimg);
00085 
00086     gmin = (PIXEL) 10.0;
00087     gmax = (PIXEL) 255.0;
00088     STRETCH(in, tf, &strimg);
00089 
00090     COMBINE(strimg, inverseimg, MINIMUM, 1.0, 1.0, &imga);
00091     RELIMG(&inverseimg);
00092 
00093     COMBINE(strimg, binimg, MAXIMUM, 1.0, 1.0, &imgb);
00094     RELIMG(&strimg);
00095 
00096     if (color == RED) {
00097         rgbimg[0] = imgb;
00098         rgbimg[1] = imga;
00099         rgbimg[2] = imga;
00100 
00101     } else if (color == BLUE) {
00102         rgbimg[0] = imga;
00103         rgbimg[1] = imga;
00104         rgbimg[2] = imgb;
00105     } else if (color == GREEN) {
00106         rgbimg[0] = imga;
00107         rgbimg[1] = imgb;
00108         rgbimg[2] = imga;
00109     } else {
00110         rgbimg[0] = imgb;
00111         rgbimg[1] = imgb;
00112         rgbimg[2] = imga;
00113     }
00114 
00115     BSQTOBIL(rgbimg, 3, out);
00116     RELIMG(&imga);
00117     RELIMG(&imgb);
00118         
00119     the_end:
00120     /* if (TIMES) TIMING(T_EXIT); */
00121 
00122 }
00123 
00124 
00125 
00126 
00127 
00128 

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