00001 #include "sadie.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 void RMSDIFF (
00014 IMAGE *in1,
00015 IMAGE *in2,
00016 double *diff
00017
00018 ) { register short i, j, k;
00019 char msg[SLEN];
00020
00021 if (TIMES) TIMING(T_RMSDIFF);
00022 if (NAMES) {
00023 MESSAGE('I',"");
00024 MESSAGE('I',"RMSDIFF");
00025 MESSAGE('I',"");
00026 sprintf(msg," First input image: %s",in1->text);
00027 MESSAGE('I',msg);
00028 sprintf(msg," Second input image: %s",in2->text);
00029 MESSAGE('I',msg);
00030 MESSAGE('I'," ...............");
00031 }
00032
00033
00034 if (!CHECKIMG(in1)) {
00035 MESSAGE('E'," Can't identify first image.");
00036 goto the_end;
00037 } else if (!CHECKIMG(in2)) {
00038 MESSAGE('E'," Can't identify second image.");
00039 goto the_end;
00040 } else if (in1->nbnd != in2->nbnd) {
00041 MESSAGE('E'," Number of bands must be identical in both images.");
00042 goto the_end;
00043 } else if (in1->nlin != in2->nlin) {
00044 MESSAGE('E'," Number of lines must be identical in both images.");
00045 goto the_end;
00046 } else if (in1->npix != in2->npix) {
00047 MESSAGE('E'," Number of pixels/line must be identical in both images.");
00048 goto the_end;
00049 }
00050
00051
00052 for (*diff=0.0,i=0; i<in1->nbnd; i++) {
00053 for (j=0; j<in1->nlin; j++) {
00054 for (k=0; k<in1->npix; k++) {
00055 *diff += (double)((in1->data[i][j][k]-in2->data[i][j][k])*(in1->data[i][j][k]-in2->data[i][j][k]));
00056 }
00057 }
00058 }
00059 *diff = sqrt(*diff/((double)in1->nbnd*(double)in1->nlin*(double)in1->npix));
00060
00061
00062 MESSAGE('I',"");
00063 sprintf(msg," Root-Mean-Squared Difference = %-11.4e",*diff);
00064 MESSAGE('I',msg);
00065
00066 the_end:
00067 if (TIMES) TIMING(T_EXIT);
00068 }