Changeset 16403
- Timestamp:
- Feb 11, 2008, 6:04:21 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmStackReject.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmStackReject.c
r15756 r16403 11 11 #define PIXEL_LIST_BUFFER 100 // Number of pixels to add to list at a time 12 12 13 psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions, 14 const psArray *solutions, const pmSubtractionKernels *kernels) 13 psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions, const psArray *kernels) 15 14 { 16 15 PS_ASSERT_PIXELS_NON_NULL(in, NULL); … … 18 17 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(threshold, 1.0, NULL); 19 18 PS_ASSERT_ARRAY_NON_NULL(regions, NULL); 20 PS_ASSERT_ARRAY_NON_NULL(solutions, NULL); 21 PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, solutions, NULL); 22 PS_ASSERT_PTR_NON_NULL(kernels, NULL); 19 PS_ASSERT_ARRAY_NON_NULL(kernels, NULL); 20 PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, kernels, NULL); 23 21 24 22 // Get the original image size … … 26 24 int numCols = 0, numRows = 0; // Size of original image 27 25 int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image --- should be 0,0 26 int size = 0; // Size of kernel 28 27 for (int i = 0; i < numRegions; i++) { 29 28 psRegion *region = regions->data[i]; // Region of interest … … 39 38 if (region->y1 > numRows) { 40 39 numRows = region->y1; 40 } 41 42 pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest 43 if (size == 0) { 44 size = kernel->size; 45 } else if (kernel->size != size) { 46 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Kernel sizes are not identical: %d vs %d", 47 size, kernel->size); 48 return NULL; 41 49 } 42 50 } … … 57 65 for (int i = 0; i < numRegions; i++) { 58 66 psRegion *region = regions->data[i]; // Region of interest 59 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernels, true)) { 67 pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest 68 if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) { 60 69 psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i); 61 70 psFree(convRO); … … 70 79 float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - numCols/2.0) / (float)numCols; 71 80 float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - numRows/2.0) / (float)numRows; 72 psImage * kernel = pmSubtractionKernelImage(kernels, xNorm, yNorm, false);73 if (! kernel) {81 psImage *image = pmSubtractionKernelImage(kernel, xNorm, yNorm, false); 82 if (!image) { 74 83 psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image."); 75 84 psFree(convRO); … … 78 87 } 79 88 float sum = 0.0; 80 for (int y = 0; y < kernel->numRows; y++) {81 for (int x = 0; x < kernel->numCols; x++) {82 sum += kernel->data.F32[y][x];89 for (int y = 0; y < image->numRows; y++) { 90 for (int x = 0; x < image->numCols; x++) { 91 sum += image->data.F32[y][x]; 83 92 } 84 93 } 85 psFree( kernel);94 psFree(image); 86 95 87 96 psImage *subConv = psImageSubset(convRO->image, *region); // Sub-image of convolved image … … 103 112 psFree(convolved); 104 113 105 // Now, we want to convolve the original pixels properly114 // Now, grow the mask to include everything that touches a bad pixel in the convolution 106 115 mask = psPixelsToMask(NULL, bad, psRegionSet(0, numCols, 0, numRows), 0xff); 107 int size = kernels->size; // Size of kernels108 116 for (int i = 0; i < bad->n; i++) { 109 117 int xPix = bad->data[i].x, yPix = bad->data[i].y; // Coordinates of interest
Note:
See TracChangeset
for help on using the changeset viewer.
