Changeset 16476 for trunk/psModules/src/imcombine/pmStackReject.c
- Timestamp:
- Feb 14, 2008, 1:18:34 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmStackReject.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmStackReject.c
r16423 r16476 59 59 } 60 60 61 psImage *mask = psPixelsToMask(NULL, in, psRegionSet(minCols, numCols, minRows, numRows), 0x01); // Mask 61 psImage *mask = psPixelsToMask(NULL, in, psRegionSet(minCols, numCols - 1, minRows, numRows - 1), 62 0x01); // Mask 62 63 psImage *image = psImageCopy(NULL, mask, PS_TYPE_F32); // Floating-point version, so we can convolve 63 64 psFree(mask); … … 70 71 inRO->row0 = minRows; 71 72 for (int i = 0; i < numRegions; i++) { 72 psRegion * subRegion = subRegions->data[i]; // Region of interest73 if (valid && ( subRegion->x0 > valid->x1 || subRegion->x1 < valid->x0 ||74 subRegion->y0 > valid->y1 || subRegion->y1 < valid->y0)) {73 psRegion *region = subRegions->data[i]; // Region of interest 74 if (valid && (region->x0 > valid->x1 || region->x1 < valid->x0 || 75 region->y0 > valid->y1 || region->y1 < valid->y0)) { 75 76 // Region is outside of our sub-image 76 77 continue; 77 78 } 78 79 pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest 79 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, subRegion, kernel, true)) {80 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) { 80 81 psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i); 81 82 psFree(convRO); … … 88 89 89 90 // Image of the kernel at the centre of the region 90 float xNorm = ( subRegion->x0 + 0.5 * (subRegion->x1 - subRegion->x0) - kernel->numCols/2.0) /91 float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - kernel->numCols/2.0) / 91 92 (float)kernel->numCols; 92 float yNorm = ( subRegion->y0 + 0.5 * (subRegion->y1 - subRegion->y0) - kernel->numRows/2.0) /93 float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - kernel->numRows/2.0) / 93 94 (float)kernel->numRows; 94 95 psImage *image = pmSubtractionKernelImage(kernel, xNorm, yNorm, false); … … 107 108 psFree(image); 108 109 109 psImage *subConv = psImageSubset(convRO->image, *subRegion); // Sub-image of convolved image 110 psBinaryOp(subConv, subConv, "*", psScalarAlloc(1.0 / sum, PS_TYPE_F32)); 110 // Range for normalisation 111 int yMin = PS_MAX(minRows, region->y0) - inRO->row0; 112 int yMax = PS_MIN(numRows - 1, region->y1) - inRO->row0; 113 int xMin = PS_MAX(minCols, region->x0) - inRO->col0; 114 int xMax = PS_MIN(numCols - 1, region->x1) - inRO->col0; 115 psTrace("psModules.imcombine", 2, "Normalising convolved mask image by %f over %d:%d,%d:%d\n", 116 sum, xMin, xMax, yMin, yMax); 117 for (int y = yMin; y <= yMax; y++) { 118 for (int x = xMin; x <= xMax; x++) { 119 convRO->image->data.F32[y][x] /= sum; 120 } 121 } 111 122 } 112 123 psFree(inRO); … … 116 127 // Threshold the convolved image 117 128 psPixels *bad = psPixelsAllocEmpty(PIXEL_LIST_BUFFER); // List of pixels that should be masked 118 for (int y = 0; y < numRows; y++) {119 for (int x = 0; x < numCols; x++) {129 for (int y = 0; y < convolved->numRows; y++) { 130 for (int x = 0; x < convolved->numCols; x++) { 120 131 if (convolved->data.F32[y][x] > threshold) { 121 132 bad = psPixelsAdd(bad, PIXEL_LIST_BUFFER, x, y);
Note:
See TracChangeset
for help on using the changeset viewer.
