00001 #include "sadie.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 void
00015 BSQTOBIL (IMAGE ** in,
00016
00017 short nimg,
00018 IMAGE ** out
00019
00020 )
00021 {
00022 register short i, j, k, l, m, nbnd, nlin, npix;
00023 char msg[SLEN];
00024 double pinc, psum;
00025
00026 if (TIMES)
00027 TIMING (T_BSQTOBIL);
00028 if (NAMES)
00029 {
00030 MESSAGE ('I', "");
00031 MESSAGE ('I', "BSQTOBIL");
00032 MESSAGE ('I', "");
00033 sprintf (msg, " Number of input images: %d", nimg);
00034 MESSAGE ('I', msg);
00035 for (i = 0; i < nimg; i++)
00036 {
00037 sprintf (msg, " Input image %3d: %s", i + 1, in[i]->text);
00038 MESSAGE ('I', msg);
00039 }
00040 MESSAGE ('I', " ...............");
00041 }
00042
00043
00044 for (i = 0; i < nimg; i++)
00045 {
00046 if (!CHECKIMG (in[i]))
00047 {
00048 MESSAGE ('E', " Can't identify image(s).");
00049 goto the_end;
00050 }
00051 }
00052 for (nlin = in[0]->nlin, i = 1; i < nimg; i++)
00053 {
00054 if (nlin != in[i]->nlin)
00055 {
00056 MESSAGE ('E', " Number of lines must be identical in all images.");
00057 goto the_end;
00058 }
00059 }
00060 for (npix = in[0]->npix, i = 1; i < nimg; i++)
00061 {
00062 if (npix != in[i]->npix)
00063 {
00064 MESSAGE ('E',
00065 " Number of pixels/line must be identical in all images.");
00066 goto the_end;
00067 }
00068 }
00069
00070
00071 for (nbnd = 0, i = 0; i < nimg; nbnd += in[i++]->nbnd);
00072 if (!CHECKIMG (*out))
00073 GETMEM (nbnd, nlin, npix, out);
00074 if (!*out)
00075 goto the_end;
00076
00077
00078 if (LINES && !PROGRESS (psum = 0.0))
00079 goto the_end;
00080 pinc = 1.0 / (double) nbnd / (double) nlin;
00081
00082
00083 for (m = 0, i = 0; i < nimg; i++)
00084 {
00085 for (j = 0; j < in[i]->nbnd; j++, m++)
00086 {
00087 for (k = 0; k < nlin; k++)
00088 {
00089 for (l = 0; l < npix; l++)
00090 {
00091 (*out)->data[m][k][l] = in[i]->data[j][k][l];
00092 }
00093 if (LINES && !PROGRESS (psum += pinc))
00094 goto the_end;
00095 }
00096 }
00097 }
00098
00099 the_end:
00100 if (TIMES)
00101 TIMING (T_EXIT);
00102 }