Main Page   Data Structures   File List   Data Fields   Globals  

real2com.c

Go to the documentation of this file.
00001 #include        "sadie.h"
00002 
00003 /*-Copyright Information------------------------------------------------------*/
00004 /* Copyright (c) 1990 by the University of Arizona Digital Image Analysis Lab */
00005 /*----------------------------------------------------------------------------*/
00006 /*-General Information--------------------------------------------------------*/
00007 /*                                                                            */
00008 /*   This function combines two "real" images into one "complex" image.       */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void REAL2COM (
00013 IMAGE *in1,     /*  I   Pointer to the first input image.                     */
00014 IMAGE *in2,     /*  I   Pointer to the second input image.                    */
00015 short option,   /*  I   Switch, indicating the type of real images:           */
00016                 /*      REIMAG   -   real and imaginary images are given.     */
00017                 /*      MAGPHA   -   magnitude and phase images are given.    */
00018 IMAGE **out     /*  O   Address of a pointer to the output image.             */
00019 /*----------------------------------------------------------------------------*/
00020 ) { register short i, j, k, n;
00021     char msg[SLEN];
00022 
00023     if (TIMES) TIMING(T_REAL2COM);
00024     if (NAMES) {
00025         MESSAGE('I',"");
00026         MESSAGE('I',"REAL2COM");
00027         MESSAGE('I',"");
00028         sprintf(msg," First input image:    %s",in1->text);
00029         MESSAGE('I',msg);
00030         sprintf(msg," Second input image:   %s",in2->text);
00031         MESSAGE('I',msg);
00032         if (option == REIMAG) {
00033             MESSAGE('I'," Real and imaginary images are given");
00034         } else if (option == MAGPHA) {
00035             MESSAGE('I'," Magnitude and phase images are given");
00036         }
00037         MESSAGE('I'," ...............");
00038     }
00039 
00040     /* check input */
00041     if (!CHECKIMG(in1)) {
00042         MESSAGE('E'," Can't identify first image.");
00043         goto the_end;
00044     } else if (!CHECKIMG(in2)) {
00045         MESSAGE('E'," Can't identify second image.");
00046         goto the_end;
00047     } else if (in1->nbnd != in2->nbnd) {
00048         MESSAGE('E'," Number of bands must be identical in both images.");
00049         goto the_end;
00050     } else if (in1->nlin != in2->nlin) {
00051         MESSAGE('E'," Number of lines/band must be identical in both images.");
00052         goto the_end;
00053     } else if (in1->npix != in2->npix) {
00054         MESSAGE('E'," Number of pixels/line must be identical in both images.");
00055         goto the_end;
00056     } else if (option != REIMAG  &&  option != MAGPHA) {
00057         MESSAGE('E'," Option must be either REIMAG or MAGPHA.");
00058         goto the_end;
00059     }
00060 
00061     /* create image of appropriate size */
00062     if (!CHECKIMG(*out)) GETMEM(in1->nbnd,in1->nlin,2*in1->npix,out);
00063     if (!*out) goto the_end;
00064 
00065     if (option == REIMAG) {
00066         /* combine real and imaginary parts */
00067         for (i=0; i<in1->nbnd; i++) {
00068             for (j=0; j<in1->nlin; j++) {
00069                 for (k=0,n=0; k<in1->npix; k+=1,n+=2) {
00070                     (*out)->data[i][j][n]   = in1->data[i][j][k];
00071                     (*out)->data[i][j][n+1] = in2->data[i][j][k];
00072                 }
00073             }
00074         }
00075     } else /* (option == MAGPHA) */ {
00076         /* combine magnitude and phase parts */
00077         for (i=0; i<in1->nbnd; i++) {
00078             for (j=0; j<in1->nlin; j++) {
00079                 for (k=0,n=0; k<in1->npix; k+=1,n+=2) {
00080                     (*out)->data[i][j][n]   = (PIXEL)(double)in1->data[i][j][k]*cos((double)in2->data[i][j][k]);
00081                     (*out)->data[i][j][n+1] = (PIXEL)(double)in1->data[i][j][k]*sin((double)in2->data[i][j][k]);
00082                 }
00083             }
00084         }
00085     }       
00086 
00087     the_end:
00088     if (TIMES) TIMING(T_EXIT);
00089 }

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