Go to the documentation of this file.
5 int avg_lin,
int16 *outarr)
38 int pix_minus, pix_plus, lin_minus, lin_plus;
39 int num, avg, ipx, iln, jpx, jln, jpxm;
44 printf(
"world_avg: either #pix (%d) or # lin (%d) < 2\n",
npix,
nlin);
45 printf(
" no averaging done (probably an error)\n");
49 printf(
"world_avg: avg_pix (%d) < 1, resetting to 1\n", avg_pix);
53 printf(
"world_avg: avg_lin (%d) < 1, resetting to 1\n", avg_lin);
56 if (avg_pix >
npix - 1) {
58 "world_avg: avg_pix (%d) > # pixels - 1 (# pixels = %d), resetting to %d\n",
62 if (avg_lin >
nlin - 1) {
64 "world_avg: avg_lin (%d) > # lines - 1 (# lines = %d), resetting to %d\n",
71 pix_minus = (avg_pix - 1) / 2;
72 pix_plus = avg_pix / 2;
74 lin_minus = (avg_lin - 1) / 2;
75 lin_plus = avg_lin / 2;
79 for (iln = 0; iln <
nlin; iln++) {
80 for (ipx = 0; ipx <
npix; ipx++) {
81 if (*(inarr + ipx + iln *
npix) > 0) {
87 for (jln = iln - lin_minus; jln <= iln + lin_plus; jln++) {
88 if (jln >= 0 && jln <
nlin) {
89 for (jpx = ipx - pix_minus; jpx <= ipx + pix_plus; jpx++) {
103 if (*(inarr + jpxm + jln *
npix) > 0) {
105 avg += *(inarr + jpxm + jln *
npix);
110 *(outarr + ipx + iln *
npix) = avg / num;
112 *(outarr + ipx + iln *
npix) = 0;
void world_avg(int16 *inarr, int32 nlin, int32 npix, int avg_pix, int avg_lin, int16 *outarr)