Changeset 16605 for trunk/ppStack/src/ppStackMatch.c
- Timestamp:
- Feb 22, 2008, 9:28:00 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackMatch.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackMatch.c
r15850 r16605 9 9 #include "ppStack.h" 10 10 11 #define ARRAY_BUFFER 16 // Number to add to array at a time 12 13 11 14 //#define TESTING 12 15 13 bool ppStackMatch(pmReadout * output, const pmReadout *input, const pmReadout *sourcesRO,14 const pm PSF *psf, const pmConfig *config)16 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, 17 const pmReadout *sourcesRO, const pmPSF *psf, const pmConfig *config) 15 18 { 19 assert(readout); 20 assert(regions && !*regions); 21 assert(kernels && !*kernels); 22 assert(sourcesRO); 23 assert(psf); 24 assert(config); 25 16 26 // Look up appropriate values from the ppSub recipe 17 27 bool mdok; // Status of MD lookup … … 68 78 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF 69 79 70 if (!pmReadoutFakeFromSources(fake, input->image->numCols, input->image->numRows, sources, NULL, NULL,80 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, sources, NULL, NULL, 71 81 psf, powf(10.0, -0.4 * maxMag), 0, false)) { 72 82 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF."); … … 85 95 86 96 // Do the image matching 87 if (!pmSubtractionMatch(output, NULL, input, fake, footprint, regionSize, spacing, threshold, 97 pmReadout *output = pmReadoutAlloc(NULL); // Output readout, for holding results temporarily 98 if (!pmSubtractionMatch(output, NULL, readout, fake, footprint, regionSize, spacing, threshold, 88 99 sources, stampsName, type, size, order, widths, orders, inner, ringsOrder, 89 100 binning, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad, … … 92 103 psFree(fake); 93 104 psFree(optWidths); 105 psFree(output); 94 106 return false; 95 107 } … … 97 109 psFree(optWidths); 98 110 111 // Replace original images with convolved 112 psFree(readout->image); 113 psFree(readout->mask); 114 psFree(readout->weight); 115 readout->image = psMemIncrRefCounter(output->image); 116 readout->mask = psMemIncrRefCounter(output->mask); 117 readout->weight = psMemIncrRefCounter(output->weight); 118 119 // Extract the regions and solutions used in the image matching 120 // This stops them from being freed when we iterate back up the FPA 121 *regions = psArrayAllocEmpty(ARRAY_BUFFER); // Array of regions 122 { 123 psString regex = NULL; // Regular expression 124 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_REGION); 125 psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator 126 psFree(regex); 127 psMetadataItem *item = NULL;// Item from iteration 128 while ((item = psMetadataGetAndIncrement(iter))) { 129 assert(item->type == PS_DATA_REGION); 130 *regions = psArrayAdd(*regions, ARRAY_BUFFER, item->data.V); 131 } 132 psFree(iter); 133 } 134 *kernels = psArrayAllocEmpty(ARRAY_BUFFER); // Array of kernels 135 { 136 psString regex = NULL; // Regular expression 137 psStringAppend(®ex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL); 138 psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator 139 psFree(regex); 140 psMetadataItem *item = NULL;// Item from iteration 141 while ((item = psMetadataGetAndIncrement(iter))) { 142 assert(item->type == PS_DATA_UNKNOWN); 143 // Set the normalisation dimensions, since these will be otherwise unavailable when reading the 144 // images by scans. 145 pmSubtractionKernels *kernel = item->data.V; // Kernel used in subtraction 146 kernel->numCols = readout->image->numCols; 147 kernel->numRows = readout->image->numRows; 148 149 *kernels = psArrayAdd(*kernels, ARRAY_BUFFER, kernel); 150 } 151 psFree(iter); 152 } 153 assert((*regions)->n == (*kernels)->n); 154 155 156 psFree(output); 157 99 158 return true; 100 159 }
Note:
See TracChangeset
for help on using the changeset viewer.
