Changeset 14623
- Timestamp:
- Aug 22, 2007, 3:59:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14602 r14623 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-08-2 2 02:56:53$6 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-08-23 01:59:31 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 1064 1064 1065 1065 // Convolve the image with the kernel --- we're basically applying a matched filter and then thresholding 1066 psImage *convolved = NULL; // Convolved mask image1067 1066 psPixels *out = NULL; // List of pixels that should be masked 1068 1067 for (int i = 0; i < numRegions; i++) { … … 1079 1078 // the kernel may scale the unit level that we've inserted. 1080 1079 1081 // Image of the kernel at the centre 1082 psImage *kernel = pmSubtractionKernelImage(solution, kernels, 1083 region->x0 + 0.5 * (region->x1 - region->x0), 1084 region->y0 + 0.5 * (region->y1 - region->y0)); 1080 // Image of the kernel at the centre of the region 1081 float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - numCols/2.0) / (float)numCols; 1082 float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - numRows/2.0) / (float)numRows; 1083 psImage *kernel = pmSubtractionKernelImage(solution, kernels, xNorm, yNorm); 1084 if (!kernel) { 1085 psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image."); 1086 psFree(convolved); 1087 psFree(image); 1088 return NULL; 1089 } 1085 1090 float sum = 0.0; 1086 1091 for (int y = 0; y < kernel->numRows; y++) { … … 1091 1096 psFree(kernel); 1092 1097 1093 // Threshold the convolved image 1094 float adjustedThreshold = sum * threshold; // Threshold adjusted for the kernel normalisation 1095 for (int y = region->y0; y < region->y1; y++) { 1096 for (int x = region->x0; x < region->x1; x++) { 1097 if (image->data.F32[y][x] > adjustedThreshold) { 1098 out = psPixelsAdd(out, PIXEL_LIST_BUFFER, x, y); 1099 } 1100 } 1101 } 1098 psImage *subConv = psImageSubset(convolved, *region); // Sub-image of convolved image 1099 psBinaryOp(subConv, subConv, "*", psScalarAlloc(1.0 / sum, PS_TYPE_F32)); 1102 1100 } 1103 1101 psFree(image); 1104 1102 1103 // Threshold the convolved image 1104 for (int y = 0; y < numRows; y++) { 1105 for (int x = 0; x < numCols; x++) { 1106 if (convolved->data.F32[y][x] > threshold) { 1107 out = psPixelsAdd(out, PIXEL_LIST_BUFFER, x, y); 1108 } 1109 } 1110 } 1111 psFree(convolved); 1112 1105 1113 return out; 1106 1114 }
Note:
See TracChangeset
for help on using the changeset viewer.
