From 754d7461cac09112f0e9c7b47075a9f5081b68c7 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 14 Mar 2019 16:38:05 -0400 Subject: thread contour --- tksao/frame/fitsanalysis.C | 3 ++- tksao/frame/fvcontour.C | 55 +++++++++++++++++++++++++--------------------- tksao/frame/fvcontour.h | 1 - tksao/util/convolve.C | 22 ++++++++++++++++++- tksao/util/convolve.h | 2 +- 5 files changed, 54 insertions(+), 29 deletions(-) diff --git a/tksao/frame/fitsanalysis.C b/tksao/frame/fitsanalysis.C index cad6cb7..679c4c0 100644 --- a/tksao/frame/fitsanalysis.C +++ b/tksao/frame/fitsanalysis.C @@ -52,7 +52,8 @@ void FitsImage::analysis(int which, pthread_t* thread, t_smooth_arg* targ) void* convolveThread(void* vv) { t_smooth_arg* tt = (t_smooth_arg*)vv; - convolve(tt->kernel, tt->src, tt->dest, tt->width, tt->height, tt->k); + convolve(tt->kernel, tt->src, tt->dest, 0, 0, tt->width, tt->height, + tt->width, tt->k); return NULL; } diff --git a/tksao/frame/fvcontour.C b/tksao/frame/fvcontour.C index 5f39176..f9d8a6c 100644 --- a/tksao/frame/fvcontour.C +++ b/tksao/frame/fvcontour.C @@ -242,7 +242,36 @@ void FVContour::nobin(FitsImage* fits) } // convolve - convolve(fits,kernel,img,r); + if (0) + convolve(fits,kernel,img,r); + else { + double* src = new double[size]; + if (!img) { + internalError("FVContour could not allocate enough memory"); + return; + } + for (long ii=0; iigetDataParams(((Base*)parent_)->currentContext->secMode()); + + SETSIGBUS + for(long jj=params->ymin; jjymax; jj++) { + for(long ii=params->xmin; iixmax; ii++) { + long kk = jj*width + ii; + double vv = fits->getValueDouble(kk); + if (isfinite(vv)) + src[kk] = vv; + } + } + CLEARSIGBUS + + ::convolve(kernel, src, img, + params->xmin, params->ymin, params->xmax, params->ymax, + width, r); + delete [] src; + } // now, do contours build(width, height, img, fits->dataToRef); @@ -289,30 +318,6 @@ void FVContour::convolve(FitsImage* fits, double* kernel, double* dest, int r) CLEARSIGBUS } -double* FVContour::tophat(int r) -{ - int rr = 2*r+1; - int ksz = rr*rr; - double* kernel = new double[ksz]; - memset(kernel, 0, ksz*sizeof(double)); - - double kt = 0; - for (int yy=-r; yy<=r; yy++) { - for (int xx=-r; xx<=r; xx++) { - if ((xx*xx + yy*yy) <= r*r) { - kernel[(yy+r)*rr+(xx+r)] = 1; - kt++; - } - } - } - - // normalize kernel - for (int aa=0; aa=ymin && nn=xmin && mm