- Timestamp:
- Feb 22, 2008, 9:18:11 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_080214/psModules/src/imcombine/pmStackReject.c
r16476 r16600 24 24 int numRegions = subRegions->n; // Number of regions 25 25 int numCols = 0, numRows = 0; // Size of original image 26 int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image --- should be 0,026 int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image 27 27 int size = 0; // Size of kernel 28 28 for (int i = 0; i < numRegions; i++) { … … 58 58 numRows = PS_MIN(valid->y1, numRows); 59 59 } 60 psTrace("psModules.imcombine", 1, "Rejecting [%d:%d,%d:%d]\n", minCols, numCols, minRows, numRows); 60 61 61 62 psImage *mask = psPixelsToMask(NULL, in, psRegionSet(minCols, numCols - 1, minRows, numRows - 1), … … 78 79 } 79 80 pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest 80 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) {81 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, false, true)) { 81 82 psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i); 82 83 psFree(convRO); … … 127 128 // Threshold the convolved image 128 129 psPixels *bad = psPixelsAllocEmpty(PIXEL_LIST_BUFFER); // List of pixels that should be masked 129 for (int y = 0; y < convolved->numRows; y++) {130 for (int x = 0; x < convolved->numCols; x++) {130 for (int y = size; y < convolved->numRows - size; y++) { 131 for (int x = size; x < convolved->numCols - size; x++) { 131 132 if (convolved->data.F32[y][x] > threshold) { 132 bad = psPixelsAdd(bad, PIXEL_LIST_BUFFER, x, y); 133 // Pixel coordinates in "bad" correspond to the full image 134 bad = psPixelsAdd(bad, PIXEL_LIST_BUFFER, x + minCols, y + minRows); 133 135 } 134 136 } … … 137 139 138 140 // Now, grow the mask to include everything that touches a bad pixel in the convolution 139 mask = psPixelsToMask(NULL, bad, psRegionSet(0, numCols - 1, 0, numRows - 1), 0xff);140 assert(mask->numCols == numCols && mask->numRows == numRows);141 int x0 = minCols, y0 = minRows; // Offset for mask image 142 mask = psPixelsToMask(NULL, bad, psRegionSet(x0, numCols - 1, y0, numRows - 1), 0xff); 141 143 for (int i = 0; i < bad->n; i++) { 142 int xPix = bad->data[i].x , yPix = bad->data[i].y; // Coordinates of interest144 int xPix = bad->data[i].x - x0, yPix = bad->data[i].y - y0; // Coordinates in frame of mask image 143 145 // Convolution limits 144 146 int xMin = PS_MAX(xPix - size, 0); 145 int xMax = PS_MIN(xPix + size, numCols - 1);147 int xMax = PS_MIN(xPix + size, mask->numCols - 1); 146 148 int yMin = PS_MAX(yPix - size, 0); 147 int yMax = PS_MIN(yPix + size, numRows - 1);149 int yMax = PS_MIN(yPix + size, mask->numRows - 1); 148 150 for (int y = yMin; y <= yMax; y++) { 149 151 for (int x = xMin; x <= xMax; x++) { … … 153 155 } 154 156 } 155 156 157 bad = psPixelsFromMask(bad, mask, 0xff); 157 158 psFree(mask); 158 159 160 // Convert coordinates to frame of original image 161 for (int i = 0; i < bad->n; i++) { 162 int x = bad->data[i].x + x0; 163 int y = bad->data[i].y + y0; 164 if (x < 0 || x >= numCols || y < 0 || y >= numRows) { 165 psWarning("Bad pixel coordinate %d: %d,%d --- ignored.", 166 i, x, y); 167 continue; 168 } 169 bad->data[i].x = x; 170 bad->data[i].y = y; 171 } 172 159 173 return bad; 160 174 }
Note:
See TracChangeset
for help on using the changeset viewer.
