00001 #include "sadie.h"
00002
00003 #define BAND 0
00004 #define LINE 1
00005 #define PIXEL 2
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 void
00017 ROTATECUBE (IMAGE * in,
00018 short xdir,
00019 short ydir,
00020 short zdir,
00021 short xaxis,
00022 short yaxis,
00023 short zaxis,
00024
00025 IMAGE ** out
00026
00027 )
00028 {
00029 register short i, j, k, outi, outj, outk;
00030 char msg[SLEN];
00031
00032
00033 if (!CHECKIMG (in))
00034 {
00035 MESSAGE ('E', " Can't identify input image.");
00036 goto the_end;
00037 }
00038
00039
00040 if (xaxis == yaxis || yaxis == zaxis || zaxis == xaxis)
00041 {
00042 MESSAGE ('E', " Can't map between same axis.");
00043 goto the_end;
00044 }
00045
00046 if (TIMES)
00047 TIMING (T_ROTATECUBE);
00048 if (NAMES)
00049 {
00050 MESSAGE ('I', "");
00051 MESSAGE ('I', "ROTATE CUBE");
00052 MESSAGE ('I', "");
00053 sprintf (msg, " Input image: %s", in->text);
00054 MESSAGE ('I', msg);
00055
00056 MESSAGE ('I', "");
00057 MESSAGE ('I', " Output format:");
00058 switch (zaxis)
00059 {
00060 case BAND:
00061 switch (yaxis)
00062 {
00063 case LINE:
00064 sprintf (msg, " X Axis: %c Pixel", (xdir == 0 ? '+' : '-'));
00065 MESSAGE ('I', msg);
00066 sprintf (msg, " Y Axis: %c Line", (ydir == 0 ? '+' : '-'));
00067 MESSAGE ('I', msg);
00068 sprintf (msg, " Z Axis: %c Band", (zdir == 0 ? '+' : '-'));
00069 MESSAGE ('I', msg);
00070 break;
00071 case PIXEL:
00072 sprintf (msg, " X Axis: %c Line", (xdir == 0 ? '+' : '-'));
00073 MESSAGE ('I', msg);
00074 sprintf (msg, " Y Axis: %c Pixel", (ydir == 0 ? '+' : '-'));
00075 MESSAGE ('I', msg);
00076 sprintf (msg, " Z Axis: %c Band", (zdir == 0 ? '+' : '-'));
00077 MESSAGE ('I', msg);
00078 break;
00079 }
00080 break;
00081 case LINE:
00082 switch (yaxis)
00083 {
00084 case BAND:
00085 sprintf (msg, " X Axis: %c Pixel", (xdir == 0 ? '+' : '-'));
00086 MESSAGE ('I', msg);
00087 sprintf (msg, " Y Axis: %c Band", (ydir == 0 ? '+' : '-'));
00088 MESSAGE ('I', msg);
00089 sprintf (msg, " Z Axis: %c Line", (zdir == 0 ? '+' : '-'));
00090 MESSAGE ('I', msg);
00091 break;
00092 case PIXEL:
00093 sprintf (msg, " X Axis: %c Band", (xdir == 0 ? '+' : '-'));
00094 MESSAGE ('I', msg);
00095 sprintf (msg, " Y Axis: %c Pixel", (ydir == 0 ? '+' : '-'));
00096 MESSAGE ('I', msg);
00097 sprintf (msg, " Z Axis: %c Line", (zdir == 0 ? '+' : '-'));
00098 MESSAGE ('I', msg);
00099 break;
00100 }
00101 break;
00102 case PIXEL:
00103 switch (yaxis)
00104 {
00105 case BAND:
00106 sprintf (msg, " X Axis: %c Line", (xdir == 0 ? '+' : '-'));
00107 MESSAGE ('I', msg);
00108 sprintf (msg, " Y Axis: %c Band", (ydir == 0 ? '+' : '-'));
00109 MESSAGE ('I', msg);
00110 sprintf (msg, " Z Axis: %c Pixel", (zdir == 0 ? '+' : '-'));
00111 MESSAGE ('I', msg);
00112 break;
00113 case LINE:
00114 sprintf (msg, " X Axis: %c Band", (xdir == 0 ? '+' : '-'));
00115 MESSAGE ('I', msg);
00116 sprintf (msg, " Y Axis: %c Line", (ydir == 0 ? '+' : '-'));
00117 MESSAGE ('I', msg);
00118 sprintf (msg, " Z Axis: %c Pixel", (zdir == 0 ? '+' : '-'));
00119 MESSAGE ('I', msg);
00120 break;
00121 }
00122 break;
00123 }
00124 }
00125
00126 MESSAGE ('I', " ...............");
00127
00128
00129 switch (zaxis)
00130 {
00131 case BAND:
00132 switch (yaxis)
00133 {
00134 case LINE:
00135
00136 if (!CHECKIMG (*out))
00137 {
00138 GETMEM (in->nbnd, in->nlin, in->npix, out);
00139 }
00140 if (!*out)
00141 goto the_end;
00142
00143 for (i = 0; i < in->nbnd; i++)
00144 {
00145 for (j = 0; j < in->nlin; j++)
00146 {
00147 for (k = 0; k < in->npix; k++)
00148 {
00149 outi = abs (zdir * (in->nbnd - 1) - i);
00150 outj = abs (ydir * (in->nlin - 1) - j);
00151 outk = abs (xdir * (in->npix - 1) - k);
00152 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00153 }
00154 }
00155 }
00156 break;
00157 case PIXEL:
00158
00159 if (!CHECKIMG (*out))
00160 GETMEM (in->nbnd, in->npix, in->nlin, out);
00161 if (!*out)
00162 goto the_end;
00163
00164 for (i = 0; i < in->nbnd; i++)
00165 {
00166 for (j = 0; j < in->nlin; j++)
00167 {
00168 for (k = 0; k < in->npix; k++)
00169 {
00170 outi = abs (zdir * (in->nbnd - 1) - i);
00171 outj = abs (ydir * (in->npix - 1) - k);
00172 outk = abs (xdir * (in->nlin - 1) - j);
00173 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00174 }
00175 }
00176 }
00177 break;
00178 }
00179 break;
00180 case LINE:
00181 switch (yaxis)
00182 {
00183 case BAND:
00184
00185 if (!CHECKIMG (*out))
00186 GETMEM (in->nlin, in->nbnd, in->npix, out);
00187 if (!*out)
00188 goto the_end;
00189
00190 for (i = 0; i < in->nbnd; i++)
00191 {
00192 for (j = 0; j < in->nlin; j++)
00193 {
00194 for (k = 0; k < in->npix; k++)
00195 {
00196 outi = abs (zdir * (in->nlin - 1) - j);
00197 outj = abs (ydir * (in->nbnd - 1) - i);
00198 outk = abs (xdir * (in->npix - 1) - k);
00199 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00200 }
00201 }
00202 }
00203 break;
00204 case PIXEL:
00205
00206 if (!CHECKIMG (*out))
00207 GETMEM (in->nlin, in->npix, in->nbnd, out);
00208 if (!*out)
00209 goto the_end;
00210
00211 for (i = 0; i < in->nbnd; i++)
00212 {
00213 for (j = 0; j < in->nlin; j++)
00214 {
00215 for (k = 0; k < in->npix; k++)
00216 {
00217 outi = abs (zdir * (in->nlin - 1) - j);
00218 outj = abs (ydir * (in->npix - 1) - k);
00219 outk = abs (xdir * (in->nbnd - 1) - i);
00220 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00221 }
00222 }
00223 }
00224 break;
00225 }
00226 break;
00227 case PIXEL:
00228 switch (yaxis)
00229 {
00230 case BAND:
00231
00232 if (!CHECKIMG (*out))
00233 GETMEM (in->npix, in->nbnd, in->nlin, out);
00234 if (!*out)
00235 goto the_end;
00236
00237 for (i = 0; i < in->nbnd; i++)
00238 {
00239 for (j = 0; j < in->nlin; j++)
00240 {
00241 for (k = 0; k < in->npix; k++)
00242 {
00243 outi = abs (zdir * (in->npix - 1) - k);
00244 outj = abs (ydir * (in->nbnd - 1) - i);
00245 outk = abs (xdir * (in->nlin - 1) - j);
00246 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00247 }
00248 }
00249 }
00250 break;
00251 case LINE:
00252
00253 if (!CHECKIMG (*out))
00254 GETMEM (in->npix, in->nlin, in->nbnd, out);
00255 if (!*out)
00256 goto the_end;
00257
00258 for (i = 0; i < in->nbnd; i++)
00259 {
00260 for (j = 0; j < in->nlin; j++)
00261 {
00262 for (k = 0; k < in->npix; k++)
00263 {
00264 outi = abs (zdir * (in->npix - 1) - k);
00265 outj = abs (ydir * (in->nlin - 1) - j);
00266 outk = abs (xdir * (in->nbnd - 1) - i);
00267 (*out)->data[outi][outj][outk] = in->data[i][j][k];
00268 }
00269 }
00270 }
00271 break;
00272 }
00273 break;
00274 }
00275
00276 the_end:
00277 if (TIMES)
00278 TIMING (T_EXIT);
00279 }