00001 #include "sadie.h"
00002 #include "proto.h"
00003
00004 void FINDCENTER (
00005 IMAGE *in
00006 ) { register short i, j, k;
00007 int xsum,ysum,count;
00008 float xcenter,ycenter;
00009
00010
00011
00012 if (!CHECKIMG(in)) {
00013 MESSAGE('E'," Can't identify image.");
00014 goto the_end;
00015 }
00016 RANGE(in);
00017
00018
00019 xsum = 0;
00020 ysum = 0;
00021 count = 0;
00022
00023 for (i=0; i<in->nlin; i++) {
00024 for (j=0; j<in->npix; j++) {
00025 if (in->data[0][i][j] > in->gmin) {
00026 xsum = xsum + (j+1);
00027 ysum = ysum + (i+1);
00028 count = count + 1;
00029 }
00030 }
00031 }
00032
00033 xcenter = ((float)xsum / (float)count);
00034 ycenter = ((float)ysum / (float)count);
00035
00036
00037 printf("xsum = %d, ysum = %d\n",xsum,ysum);
00038 printf("Center = (%.2f,%.2f)\n",xcenter,ycenter);
00039
00040
00041
00042 the_end:
00043
00044 }