- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/imcombine/pmStackReject.c
r21351 r27840 10 10 #include "pmSubtractionThreads.h" 11 11 #include "pmSubtractionKernels.h" 12 13 #include "pmStackReject.h" 12 14 13 15 #define PIXEL_LIST_BUFFER 100 // Number of pixels to add to list at a time … … 35 37 { 36 38 int size = kernels->size; // Half-size of convolution kernel 37 psImage *polyValues = p_pmSubtractionPolynomialFromCoords(NULL, kernels, numCols, numRows, 38 xMin + size + 1, yMin + size + 1); // Polynomial 39 int x = PS_MIN(xMin + size + 1, kernels->xMax); // x coordinate of interest 40 int y = PS_MIN(yMin + size + 1, kernels->yMax); // y coordinate of interest 41 42 psImage *polyValues = p_pmSubtractionPolynomialFromCoords(NULL, kernels, x, y); // Polynomial 39 43 int box = p_pmSubtractionBadRadius(NULL, kernels, polyValues, false, poorFrac); // Radius of bad box 40 44 psTrace("psModules.imcombine", 10, "Growing by %d", box); … … 43 47 if (box > 0) { 44 48 // Convolve a subimage, then stick it in the target 45 // XXX if (threaded) {46 // XXX psMutexLock(source);47 // XXX }48 49 psImage *mask = psImageSubset(source, psRegionSet(xMin - box, xMax + box, 49 50 yMin - box, yMax + box)); // Mask to convolve 50 // XXX if (threaded) {51 // XXX psMutexUnlock(source);52 // XXX }53 51 psImage *convolved = psImageConvolveMask(NULL, mask, PM_STACK_MASK_BAD, PM_STACK_MASK_CONVOLVE, 54 52 -box, box, -box, box); // Convolved mask 55 // XXX if (threaded) {56 // XXX psMutexLock(source);57 // XXX }58 53 psFree(mask); 59 // XXX if (threaded) {60 // XXX psMutexUnlock(source);61 // XXX }62 54 63 55 int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy … … 111 103 112 104 if (!pmSubtractionThreaded()) { 113 pmSubtractionThreadsInit( NULL, NULL);105 pmSubtractionThreadsInit(); 114 106 } 115 107 … … 125 117 126 118 127 psPixels *pmStackReject(const psPixels *in, int numCols, int numRows, float threshold, float poorFrac,128 int stride,const psArray *subRegions, const psArray *subKernels)119 psPixels *pmStackReject(const psPixels *in, int numCols, int numRows, float threshold, int stride, 120 const psArray *subRegions, const psArray *subKernels) 129 121 { 130 122 PS_ASSERT_PIXELS_NON_NULL(in, NULL); … … 162 154 pmReadout *inRO = pmReadoutAlloc(NULL); // Readout with input image 163 155 inRO->image = image; 164 // XXX if (threaded) { 165 // XXX psMutexInit(image); 166 // XXX } 156 convRO->image = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32); 167 157 for (int i = 0; i < numRegions; i++) { 168 158 psRegion *region = subRegions->data[i]; // Region of interest 169 159 pmSubtractionKernels *kernels = subKernels->data[i]; // Kernel of interest 170 if (!pmSubtractionConvolve( convRO, NULL, inRO, NULL, NULL, stride, 0, 0, 1.0, 0.0,160 if (!pmSubtractionConvolve(NULL, convRO, NULL, inRO, NULL, stride, 0, 0, 1.0, 0.0, 0.0, 171 161 region, kernels, false, true)) { 172 psError( PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);162 psError(psErrorCodeLast(), false, "Unable to convolve mask image in region %d.", i); 173 163 psFree(convRO); 174 164 psFree(inRO); … … 180 170 181 171 // Image of the kernel at the centre of the region 182 float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - kernels->numCols/2.0) / 183 (float)kernels->numCols; 184 float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - kernels->numRows/2.0) / 185 (float)kernels->numRows; 186 psImage *kernel = pmSubtractionKernelImage(kernels, xNorm, yNorm, false); 172 psImage *kernel = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); 187 173 if (!kernel) { 188 psError( PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");174 psError(psErrorCodeLast(), false, "Unable to generate kernel image."); 189 175 psFree(convRO); 190 176 psFree(inRO); … … 211 197 } 212 198 } 213 // XXX if (threaded) {214 // XXX psMutexDestroy(image);215 // XXX }216 199 psFree(inRO); 217 200 psImage *convolved = psMemIncrRefCounter(convRO->image); … … 241 224 } 242 225 psTrace("psModules.imcombine", 7, "Found %ld bad pixels", bad->n); 243 244 // Now, grow the mask to include everything that touches a bad pixel in the convolution 245 psImage *source = psPixelsToMask(NULL, bad, psRegionSet(0, numCols - 1, 0, numRows - 1), 226 psFree(convolved); 227 228 return bad; 229 } 230 231 232 psPixels *pmStackRejectGrow(const psPixels *in, int numCols, int numRows, float poorFrac, 233 const psArray *subRegions, const psArray *subKernels) 234 { 235 PS_ASSERT_PIXELS_NON_NULL(in, NULL); 236 PS_ASSERT_ARRAY_NON_NULL(subRegions, NULL); 237 PS_ASSERT_ARRAY_NON_NULL(subKernels, NULL); 238 PS_ASSERT_ARRAYS_SIZE_EQUAL(subRegions, subKernels, NULL); 239 240 psImage *source = psPixelsToMask(NULL, in, psRegionSet(0, numCols - 1, 0, numRows - 1), 246 241 PM_STACK_MASK_BAD); // Mask image to grow 247 242 … … 262 257 bool oldThreads = psImageConvolveSetThreads(false); // Old value of threading for psImageColvolve 263 258 264 psImage *target = psImage Recycle(convolved,numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image259 psImage *target = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image 265 260 psImageInit(target, 0); 266 // XXX if (threaded) {267 // XXX psMutexInit(source);268 // XXX }269 261 for (int i = 0; i < subRegions->n; i++) { 270 262 psRegion *region = subRegions->data[i]; // Subtraction region … … 287 279 psArray *args = job->args; // Job arguments 288 280 psArrayAdd(args, 1, target); 289 // XXX psMutexLock(source);290 281 psArrayAdd(args, 1, source); 291 // XXX psMutexUnlock(source);292 282 psArrayAdd(args, 1, kernels); 293 283 PS_ARRAY_ADD_SCALAR(args, numCols, PS_TYPE_S32); … … 307 297 } else if (!stackRejectGrow(target, source, kernels, numCols, numRows, 308 298 i, xSubMax, j, ySubMax, poorFrac)) { 309 psError( PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");299 psError(psErrorCodeLast(), false, "Unable to grow bad pixels."); 310 300 psFree(source); 311 301 psFree(target); … … 317 307 318 308 if (!psThreadPoolWait(false)) { 319 psError( PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");309 psError(psErrorCodeLast(), false, "Unable to grow bad pixels."); 320 310 psFree(source); 321 311 psFree(target); … … 332 322 } 333 323 334 // XXX psMutexDestroy(source);335 324 } 336 325 … … 351 340 352 341 psFree(source); 353 bad = psPixelsFromMask(bad, target, PM_STACK_MASK_ALL); 342 psPixels *bad = psPixelsFromMask(NULL, target, PM_STACK_MASK_ALL); // All bad pixels 343 psFree(target); 354 344 psTrace("psModules.imcombine", 7, "Total %ld bad pixels", bad->n); 355 345
Note:
See TracChangeset
for help on using the changeset viewer.
