Changeset 9612
- Timestamp:
- Oct 17, 2006, 10:38:42 AM (20 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmFlatField.c (modified) (7 diffs)
-
pmFlatField.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFlatField.c
r7858 r9612 1 /** @file pmFlatField.c2 *3 * @brief Given an input image and a flat field image, pmFlatField shall divide the input image by the flat4 * field image.5 *6 * The input image, in, and the flat field image, flat, need not be the same size, since the input image may7 * already have been trimmed (following overscan subtraction), but the function shall use the offsets in the8 * image (in->x0 and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat9 * field. In the event that the flat image is too small (i.e., pixels on the input image refer to pixels10 * outside the range of the flat image), the function shall generate an error. Pixels which are negative or11 * zero in the flat shall be masked in the input image with the value PM_MASK_FLAT. Negative pixels in the12 * flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat13 * shall be masked with corresponding values in the output. The function shall not normalize the flat; this14 * responsibility is left to the caller. This function is basically equivalent to a divide (with psImageOp),15 * but with care for the region that is divided, checking for negative pixels, and copying of the mask from16 * the flat to the output.17 *18 * @author Ross Harman, MHPCC19 *20 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $21 * @date $Date: 2006-07-10 20:54:52 $22 *23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii24 */25 26 1 #if HAVE_CONFIG_H 27 2 #include <config.h> … … 29 4 30 5 #include <stdio.h> 31 #include <math.h> 32 #include <strings.h> 6 #include <pslib.h> 33 7 34 #include <pslib.h>35 8 #include "pmFPA.h" 36 9 #include "pmFlatField.h" 37 10 #include "pmFPAMaskWeight.h" 38 #include "pmFlatFieldErrors.h"39 11 40 12 … … 52 24 } 53 25 PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false); 26 if (flat->mask) { 27 PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_MASK, false); 28 PS_ASSERT_IMAGES_SIZE_EQUAL(flat->mask, flat->image, false); 29 } 54 30 55 31 psImage *inImage = in->image; // Input image 56 32 psImage *inMask = in->mask; // Mask for input image 57 33 psImage *flatImage = flat->image; // Flat-field image 34 psImage *flatMask = flat->mask; // Mask for flat-field image 58 35 59 36 // Check input image is not larger than flat image; mask is the same size as the input … … 71 48 72 49 // Determine offset based on image offset with chip offset: input frame to flat frame 73 int yOffset = in->row0 + y0in - flat-> col0 - y0flat;74 int xOffset = in-> row0 + x0in - flat->col0 - x0flat;50 int yOffset = in->row0 + y0in - flat->row0 - y0flat; 51 int xOffset = in->col0 + x0in - flat->col0 - x0flat; 75 52 76 53 // Check that offsets are within image limits … … 88 65 for (int j = 0; j < inImage->numRows; j++) { \ 89 66 for (int i = 0; i < inImage->numCols; i++) { \ 90 if (flatImage->data.TYPE[j][i] <= 0.0) { \ 67 ps##TYPE flatValue = flatImage->data.TYPE[j + yOffset][i + xOffset]; \ 68 if (flatValue <= 0.0 || (flatMask && flatMask->data.U8[j + yOffset][i + xOffset])) { \ 91 69 if (inMask) { \ 92 70 inMask->data.U8[j][i] |= PM_MASK_FLAT; \ … … 94 72 inImage->data.TYPE[j][i] = SPECIAL; \ 95 73 } else { \ 96 inImage->data.TYPE[j][i] /= flat Image->data.TYPE[j][i]; \74 inImage->data.TYPE[j][i] /= flatValue; \ 97 75 } \ 98 76 } \ … … 112 90 FLAT_DIVISION_CASE(F64, NAN); 113 91 default: 114 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unsupported type for input image: %x\n", inImage->type.type); 92 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unsupported type for input image: %x\n", 93 inImage->type.type); 115 94 return false; 116 95 } -
trunk/psModules/src/detrend/pmFlatField.h
r7278 r9612 1 /// @file pmFlatField.h 2 /// 3 /// @brief Apply flat field calibration 4 /// 5 /// @ingroup Detrend 6 /// 7 /// @author Ross Harman, MHPCC 8 /// @author Paul Price, IfA 9 /// 10 /// @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 11 /// @date $Date: 2006-10-17 20:38:42 $ 12 /// 13 /// Copyright 2004-2006 Institute for Astronomy, University of Hawaii 14 /// 15 1 16 /** @file pmFlatField.h 2 17 * … … 18 33 * @author Ross Harman, MHPCC 19 34 * 20 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $21 * @date $Date: 2006- 06-02 00:55:23$35 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 36 * @date $Date: 2006-10-17 20:38:42 $ 22 37 * 23 38 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 24 39 */ 25 40 26 #include "pslib.h" 41 42 27 43 #include "pmFPA.h" 28 44 … … 35 51 * @return bool: True or false for success or failure 36 52 */ 37 bool pmFlatField(38 pmReadout *in, ///< Readout with input image39 const pmReadout *flat ///< Readout with flat image40 );41 53 54 55 /// Apply flat field calibration to a readout 56 /// 57 /// This function applies the flat field calibration to the input readout. Support is available for different 58 /// image types, though the input and flat images must have the same type. The relative offsets between the 59 /// input and flat images is determined from the readout row0,col0 and the CELL.X0 and CELL.Y0 concepts. 60 /// Normalisation of the flat is left as the responsibility of the caller. Negative pixels in the flat are 61 /// masked, if there is a mask present in the input readout. 62 bool pmFlatField(pmReadout *in, ///< Readout with input image 63 const pmReadout *flat ///< Readout with flat image 64 ); 65
Note:
See TracChangeset
for help on using the changeset viewer.
