Changeset 9612 for trunk/psModules/src/detrend/pmFlatField.c
- Timestamp:
- Oct 17, 2006, 10:38:42 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmFlatField.c (modified) (7 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 }
Note:
See TracChangeset
for help on using the changeset viewer.
