- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_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/tap_branches/psModules/src/imcombine/pmStackReject.c
r25468 r27838 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); … … 99 103 100 104 if (!pmSubtractionThreaded()) { 101 pmSubtractionThreadsInit( NULL, NULL);105 pmSubtractionThreadsInit(); 102 106 } 103 107 … … 113 117 114 118 115 psPixels *pmStackReject(const psPixels *in, int numCols, int numRows, float threshold, float poorFrac,116 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) 117 121 { 118 122 PS_ASSERT_PIXELS_NON_NULL(in, NULL); … … 150 154 pmReadout *inRO = pmReadoutAlloc(NULL); // Readout with input image 151 155 inRO->image = image; 156 convRO->image = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32); 152 157 for (int i = 0; i < numRegions; i++) { 153 158 psRegion *region = subRegions->data[i]; // Region of interest 154 159 pmSubtractionKernels *kernels = subKernels->data[i]; // Kernel of interest 155 if (!pmSubtractionConvolve(NULL, convRO, NULL, inRO, 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, 156 161 region, kernels, false, true)) { 157 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); 158 163 psFree(convRO); 159 164 psFree(inRO); … … 165 170 166 171 // Image of the kernel at the centre of the region 167 float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - kernels->numCols/2.0) / 168 (float)kernels->numCols; 169 float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - kernels->numRows/2.0) / 170 (float)kernels->numRows; 171 psImage *kernel = pmSubtractionKernelImage(kernels, xNorm, yNorm, false); 172 psImage *kernel = pmSubtractionKernelImage(kernels, 0.5, 0.5, false); 172 173 if (!kernel) { 173 psError( PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");174 psError(psErrorCodeLast(), false, "Unable to generate kernel image."); 174 175 psFree(convRO); 175 176 psFree(inRO); … … 223 224 } 224 225 psTrace("psModules.imcombine", 7, "Found %ld bad pixels", bad->n); 225 226 // Now, grow the mask to include everything that touches a bad pixel in the convolution 227 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), 228 241 PM_STACK_MASK_BAD); // Mask image to grow 229 242 … … 244 257 bool oldThreads = psImageConvolveSetThreads(false); // Old value of threading for psImageColvolve 245 258 246 psImage *target = psImage Recycle(convolved,numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image259 psImage *target = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image 247 260 psImageInit(target, 0); 248 261 for (int i = 0; i < subRegions->n; i++) { … … 284 297 } else if (!stackRejectGrow(target, source, kernels, numCols, numRows, 285 298 i, xSubMax, j, ySubMax, poorFrac)) { 286 psError( PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");299 psError(psErrorCodeLast(), false, "Unable to grow bad pixels."); 287 300 psFree(source); 288 301 psFree(target); … … 294 307 295 308 if (!psThreadPoolWait(false)) { 296 psError( PS_ERR_UNKNOWN, false, "Unable to grow bad pixels.");309 psError(psErrorCodeLast(), false, "Unable to grow bad pixels."); 297 310 psFree(source); 298 311 psFree(target); … … 327 340 328 341 psFree(source); 329 bad = psPixelsFromMask(bad, target, PM_STACK_MASK_ALL); 342 psPixels *bad = psPixelsFromMask(NULL, target, PM_STACK_MASK_ALL); // All bad pixels 343 psFree(target); 330 344 psTrace("psModules.imcombine", 7, "Total %ld bad pixels", bad->n); 331 345
Note:
See TracChangeset
for help on using the changeset viewer.
