Changeset 2670
- Timestamp:
- Dec 8, 2004, 3:12:31 PM (22 years ago)
- Location:
- trunk/stac/src
- Files:
-
- 5 edited
-
Makefile (modified) (3 diffs)
-
stac.c (modified) (1 diff)
-
stac.h (modified) (1 diff)
-
stacCombine.c (modified) (7 diffs)
-
stacRejection.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/Makefile
r2661 r2670 1 1 SHELL = /bin/sh 2 2 CC = gcc 3 CFLAGS += -O2 -g -std=c99 -I/home/mithrandir/price/psLib3/psLib/include -D TESTING -DCRFLUX3 CFLAGS += -O2 -g -std=c99 -I/home/mithrandir/price/psLib3/psLib/include -DCRFLUX 4 4 PSLIB += -L/home/mithrandir/price/psLib3/psLib/lib/ -lpslib -lgsl -lgslcblas -lfftw3f -lsla -lcfitsio -lm 5 5 LDFLAGS += $(PSLIB) … … 21 21 $(CC) $(CFLAGS) -o $@ calcGrad.o $(LDFLAGS) $(OPTFLAGS) 22 22 23 median: median.o 24 $(CC) $(CFLAGS) -o $@ median.o $(LDFLAGS) $(OPTFLAGS) 25 26 23 27 clean: 24 28 -$(RM) *.o gmon.* profile.txt … … 37 41 -$(RM) test_[0-3].fits.shifterr.* 38 42 -$(RM) leaks.dat 39 ./stac -v -k 2.5 -f 0.3 -G 0.6testout.fits test_0.fits test_1.fits test_2.fits test_3.fits43 ./stac -v -k 3 -f 0.7 -G 0.77 testout.fits test_0.fits test_1.fits test_2.fits test_3.fits 40 44 41 45 # Run profiling. -
trunk/stac/src/stac.c
r2500 r2670 58 58 59 59 // Transform rejected pixels to source frame 60 psArray *rejectedSource = stacRejection(inputs, transformed, combined, maps, rejected, config);60 psArray *rejectedSource = stacRejection(inputs, transformed, combined, maps, inverseMaps, rejected, config); 61 61 62 62 // Redo transformation with the mask -
trunk/stac/src/stac.h
r2661 r2670 140 140 psImage *combined, // Combined image 141 141 psArray *maps, // Maps from input to transformed image 142 psArray *inverseMaps, // Maps from transformed to input image 142 143 psArray *rejected, // Rejected images 143 144 stacConfig *config // Configuration -
trunk/stac/src/stacCombine.c
r2661 r2670 14 14 #if 0 15 15 // Would like to use psVectorStats, but it doesn't have errors built in yet 16 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);16 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 17 17 (void)psVectorStats(stats, values, masks, 1); 18 18 float mean = stats->sampleMean; … … 25 25 int num = values->n; 26 26 for (int i = 0; i < num; i++) { 27 if ( masks->data.U8[i]) {27 if (! masks->data.U8[i]) { 28 28 sum += values->data.F32[i] / SQUARE(errors->data.F32[i]); 29 29 weights += 1.0 / SQUARE(errors->data.F32[i]); … … 46 46 { 47 47 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 48 (void)psVectorStats(stats, values, masks, 0);48 (void)psVectorStats(stats, values, masks, 1); 49 49 float median = stats->sampleMedian; 50 50 psFree(stats); … … 132 132 deltas->data.F32[i] = delta; 133 133 if ((pixel >= saturated) || (pixel <= bad) || (! isfinite(pixel)) || (! isfinite(delta))) { 134 mask->data.U8[i] = (psU8) 0; // Don't use!134 mask->data.U8[i] = (psU8)1; // Don't use! 135 135 } else { 136 mask->data.U8[i] = (psU8) 1; // Use.136 mask->data.U8[i] = (psU8)0; // Use. 137 137 } 138 138 } 139 139 140 float average = stacCombineMe dian(pixels, deltas, mask); // Combined value140 float average = stacCombineMean(pixels, deltas, mask); // Combined value 141 141 142 142 #ifdef TESTING … … 145 145 int numGoodPix = 0; 146 146 for (int i = 0; i < nImages; i++) { 147 if ( mask->data.U8[i]) {147 if (! mask->data.U8[i]) { 148 148 chi2->data.F32[y][x] += SQUARE((pixels->data.F32[i] - average) / deltas->data.F32[i]); 149 149 numGoodPix++; … … 158 158 int maxIndex = -1; 159 159 for (int i = 0; i < nImages; i++) { 160 if ( mask->data.U8[i] && ((pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) {160 if (!mask->data.U8[i] && ((pixels->data.F32[i] - average) / deltas->data.F32[i] > max)) { 161 161 max = (pixels->data.F32[i] - average) / deltas->data.F32[i]; 162 162 maxIndex = i; … … 165 165 // Reject the pixel with the maximum deviation 166 166 if (max > reject) { 167 mask->data.U8[maxIndex] = 0;167 mask->data.U8[maxIndex] = 1; 168 168 ((psImage*)((*rejected)->data[maxIndex]))->data.F32[y][x] += 1.0; 169 169 // Re-do combination following rejection -
trunk/stac/src/stacRejection.c
r2661 r2670 11 11 ) 12 12 { 13 float sum = 0.0; // The sum of surrounding pixels14 13 int num = 0; 15 psVector *pixels = psVectorAlloc( 9, PS_TYPE_F32); // Array of pixels16 psVector *mask = psVectorAlloc( 9, PS_TYPE_U8); // Corresponding mask14 psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels 15 psVector *mask = psVectorAlloc(8, PS_TYPE_U8); // Corresponding mask 17 16 18 17 // Get limits … … 23 22 for (int j = yMin; j <= yMax; j++) { 24 23 for (int i = xMin; i <= xMax; i++) { 25 sum += image->data.F32[j][i]; 26 pixels->data.F32[num] = image->data.F32[j][i]; 27 mask->data.U8[num] = 1; 28 num++; 29 } 30 } 31 #if 0 32 sum -= image->data.F32[y][x]; 33 sum /= (float)(num-1); 34 // sum -= image->data.F32[y][x]; 35 return sum / image->data.F32[y][x]; 36 #endif 37 38 // Fill out the array 39 for (int i = num; i < 9; i++) { 40 pixels->data.F32[i] = 0; 41 mask->data.U8[i] = 0; 42 } 24 if ((i != x) && (j != y)) { 25 pixels->data.F32[num] = image->data.F32[j][i]; 26 mask->data.U8[num] = 0; 27 num++; 28 } 29 } 30 } 31 pixels->n = num; 32 mask->n = num; 33 34 // Get the median 43 35 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 44 (void)psVectorStats(stats, pixels, mask, 0);36 (void)psVectorStats(stats, pixels, mask, 1); 45 37 float median = stats->sampleMedian; 46 38 psFree(stats); … … 85 77 psImage *combined, // Combined image 86 78 psArray *maps, // Maps from input to transformed image 79 psArray *inverseMaps, // Maps from transformed to input image 87 80 psArray *rejected, // Rejected images 88 81 stacConfig *config // Configuration … … 167 160 #ifdef TESTING 168 161 rejmap->data.F32[y][x] = maskVal; 169 grad->data.F32[y][x] = stacGradient(inputs->data[i], x, y); 170 #endif 171 // Check threshold, then check gradient 172 if ((maskVal > config->frac) && (stacGradient(inputs->data[i], x, y) < config->grad)) { 173 mask->data.U8[y][x] = 1; 174 nBad++; 162 #endif 163 164 // Check gradient 165 float meanGrads = 0.0; 166 int numGrads = 0; 167 for (int j = 0; j < nImages; j++) { 168 if (i != j) { 169 // Get coordinates for that image 170 (void)psPlaneTransformApply(inCoords, inverseMaps->data[j], outCoords); 171 int xPix = (int)(inCoords->x + 0.5); 172 int yPix = (int)(inCoords->y + 0.5); 173 if ((xPix >= 0) && (xPix <= ((psImage*)(inputs->data[j]))->numCols - 1) && 174 (yPix >= 0) && (yPix <= ((psImage*)(inputs->data[j]))->numRows - 1)) { 175 // Calculate the gradient 176 meanGrads += stacGradient(inputs->data[j], xPix, yPix); 177 numGrads++; 178 } 179 } 180 } 181 if (numGrads > 0) { 182 meanGrads /= (float)numGrads; 183 } else { 184 meanGrads = 0; 185 } 186 187 #ifdef TESTING 188 grad->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads; 189 #endif 190 if (maskVal > config->frac) { 191 192 if ((maskVal > config->frac) && 193 (stacGradient(inputs->data[i], x, y)) < config->grad * meanGrads) { 194 mask->data.U8[y][x] = 1; 195 nBad++; 175 196 #ifdef CRFLUX 176 fprintf(crs, "%d %d --> %f %f %f\n", x, y, ((psImage*)(inputs->data[i]))->data.F32[y][x], 177 maskVal, stacGradient(inputs->data[i], x, y)); 197 fprintf(crs, "%d %d --> %f %f %f\n", x, y, ((psImage*)(inputs->data[i]))->data.F32[y][x], 198 maskVal, stacGradient(inputs->data[i], x, y)); 199 } 178 200 #endif 179 201 } else { … … 189 211 #endif 190 212 191 psTrace("stac.rejection", 1, "%d pixels masked in image %d .\n", nBad, i);213 psTrace("stac.rejection", 1, "%d pixels masked in image %d\n", nBad, i); 192 214 // Clip the image, and convert to suitable mask format 193 215
Note:
See TracChangeset
for help on using the changeset viewer.
