00001 #include "sadie.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 void REAL2COM (
00013 IMAGE *in1,
00014 IMAGE *in2,
00015 short option,
00016
00017
00018 IMAGE **out
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
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
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
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 {
00076
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 }