Changeset 28300
- Timestamp:
- Jun 10, 2010, 2:45:18 PM (16 years ago)
- Location:
- trunk/ppBackground/src
- Files:
-
- 3 edited
-
ppBackground.h (modified) (1 diff)
-
ppBackgroundLoop.c (modified) (2 diffs)
-
ppBackgroundRestore.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppBackground/src/ppBackground.h
r28296 r28300 39 39 /// Restore the background to an image 40 40 bool ppBackgroundRestore( 41 pmChip *out, // Output chip 42 const pmChip *chip, // Input chip 41 pmChip *chip, // Chip to correct 43 42 const pmChip *background, // Chip with background model 44 43 const pmChip *pattern, // Chip with pattern -
trunk/ppBackground/src/ppBackgroundLoop.c
r28296 r28300 86 86 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 87 87 psImageInit(readout->image, 0.0); 88 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 89 psImageInit(readout->mask, 0); 88 90 89 91 if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) { … … 116 118 } 117 119 118 pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern 119 if (!mosaic->hdu && !mosaic->parent->hdu) { 120 pmFPAAddSourceFromView(patternMosaic, view, file->format); 120 if (data->patternName) { 121 pmChip *patternChip = pmFPAviewThisChip(view, patternFile->fpa); // Chip for pattern 122 pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern 123 if (!mosaic->hdu && !mosaic->parent->hdu) { 124 pmFPAAddSourceFromView(patternMosaic, view, file->format); 125 } 126 if (!pmChipMosaic(mosaic, patternChip, true, maskBad)) { 127 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction"); 128 return false; 129 } 130 pmFPAfileActivate(config->files, true, NULL); 131 // pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN"); 121 132 } 122 if (!pmChipMosaic(mosaic, chip, true, maskBad)) {123 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");124 return false;125 }126 pmFPAfileActivate(config->files, true, NULL);127 // pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");128 133 } 129 134 130 pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPBACKGROUND.OUTPUT"); // Chip for output131 135 pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern 132 136 pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model 133 if (!ppBackgroundRestore( outChip,chip, bgChip, patternChip, view, config)) {137 if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) { 134 138 psError(psErrorCodeLast(), false, "Unable to replace background"); 135 139 return false; -
trunk/ppBackground/src/ppBackgroundRestore.c
r28296 r28300 6 6 #include "ppBackground.h" 7 7 8 bool ppBackgroundRestore(pmChip * out, const pmChip *chip, const pmChip *background, const pmChip *pattern,8 bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern, 9 9 const pmFPAview *oldView, pmConfig *config) 10 10 { 11 PS_ASSERT_PTR_NON_NULL(out, false);12 11 PS_ASSERT_PTR_NON_NULL(chip, false); 13 12 PS_ASSERT_PTR_NON_NULL(oldView, false); … … 18 17 view->readout = 0; 19 18 20 pmReadout * inRO= pmFPAviewThisReadout(view, chip->parent);21 if (! inRO || !inRO->data_exists) {19 pmReadout *ro = pmFPAviewThisReadout(view, chip->parent); 20 if (!ro || !ro->data_exists) { 22 21 psError(PPBACKGROUND_ERR_CONFIG, true, "Readout has no data"); 23 22 return false; 24 23 } 25 const psImage *inImage = inRO->image, *inMask = inRO->mask; // Input image 26 int numCols = inImage->numCols, numRows = inImage->numRows; // Size of image 27 28 pmReadout *outRO = pmFPAviewThisReadout(view, out->parent); 29 if (!outRO) { 30 pmCell *outCell = pmFPAviewThisCell(view, out->parent); 31 outRO = pmReadoutAlloc(outCell); 32 psFree(outRO); // Drop reference 33 } 34 outRO->image = psImageCopy(outRO->image, inImage, PS_TYPE_F32); 35 outRO->mask = psImageCopy(outRO->mask, inMask, PS_TYPE_IMAGE_MASK); 36 psImage *outImage = outRO->image, *outMask = outRO->mask; // Output image 24 const psImage *image = ro->image, *mask = ro->mask; // Input image 25 int numCols = image->numCols, numRows = image->numRows; // Size of image 37 26 38 27 if (background) { 39 28 pmReadout *bgRO = pmFPAviewThisReadout(view, background->parent); // Readout with background 40 psImageBinning *binning = psphotBackgroundBinning( outImage, config);29 psImageBinning *binning = psphotBackgroundBinning(image, config); 41 30 if (!binning) { 42 31 psError(psErrorCodeLast(), false, "Unable to find background binning"); … … 60 49 for (int y = 0; y < numRows; y++) { 61 50 for (int x = 0; x < numCols; x++) { 62 outImage->data.F32[y][x] += bgImage->data.F32[y][x];51 image->data.F32[y][x] += bgImage->data.F32[y][x]; 63 52 } 64 53 } … … 72 61 for (int y = 0; y < numRows; y++) { 73 62 for (int x = 0; x < numCols; x++) { 74 outImage->data.F32[y][x]= patternImage->data.F32[y][x];75 outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];63 image->data.F32[y][x] -= patternImage->data.F32[y][x]; 64 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]; 76 65 } 77 66 } 78 67 } 79 68 80 outRO->data_exists = true;81 outRO->parent->data_exists = true;82 outRO->parent->parent->data_exists = true;69 ro->data_exists = true; 70 ro->parent->data_exists = true; 71 ro->parent->parent->data_exists = true; 83 72 84 73 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
