# include # include # include "biaseq.h" /* FINDJUMPS -- Find bias jumps within image quadrants. ** ** ** ** Revision history: ** ---------------- ** H. Bushouse 03-May-2000 Implementation. ** */ int findJumps (SingleNicmosGroup *bias, int cam, short bitmask, int filtsz, float thresh, int *jmplim, int *njmps) { /* Arguments: ** bias i: bias image ** cam i: camera number ** bitmask i: DQ bit mask ** filtsz i: median filter size ** thresh i: jump detection threshold ** jmplim o: array of jump limits ** njmps o: number of jumps */ /* Local variables */ int i, j, q; /* loop indexes */ float mean, median, mode; /* image statistics */ float stdv, min, max; /* image statistics */ float *vect, *fvect; /* median vectors */ /* Function declarations */ int n_stats (SingleNicmosGroup *, int, int, int, int, float, float, short, float *, float *, float *, float *, float *, float *); void vect_filt (float *, int, int, float *); void vect_stats (float *, float, int, float *); /* Allocate memory for row/column vectors */ vect = (float *)calloc(NIC_QSIZE, sizeof(float)); fvect = (float *)calloc(NIC_QSIZE, sizeof(float)); for (i=0; i thresh*stdv) { jmplim[2*(*njmps-1)+1] = i; /* end of region */ jmplim[2*(*njmps-1)+2] = i+1; /* start of next */ (*njmps)++; } } /* Set end of last region to last pixel in quadrant */ jmplim[2*(*njmps-1)+1] = NIC_QSIZE-1; /* Free memory */ free (vect); free (fvect); /* Successful return */ return (0); } void vect_filt (float *in, int in_len, int width, float *out) { /* Local variables */ int i, j; /* loop indexes */ int npts; /* number of points in array */ int half_width; /* half width of filter */ float *arr; /* work array */ /* Function declarations */ int sort (float *, int); float findMedian (float *, int); /* Allocate memory for work array */ arr = (float *)calloc(width, sizeof(float)); half_width = (int)(width/2); /* Loop through vector, computing median around each point */ for (i=0; i=0 && j low && val < upp) { arr[npix] = val; sum += val; sum2 += val*val; npix++; } } /* Compute stats */ if (npix < 2) { *mean = 0.0; *median = 0.0; *stdv = 0.0; } else { *mean = sum / npix; sort(arr-1, npix); *median = findMedian (arr, npix); *stdv = npix/(npix-1.) * (sum2/npix - (*mean)*(*mean)); if (*stdv >= 0) *stdv = sqrt (*stdv); else *stdv = 0.0; } /* Free memory */ free (arr); }