IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 17, 2006, 10:38:42 AM (20 years ago)
Author:
Paul Price
Message:

Documenting pmFlatField.h. Fixing pmFlatField so that the image offsets are actually applied when flat-fielding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFlatField.c

    r7858 r9612  
    1 /** @file  pmFlatField.c
    2  *
    3  *  @brief Given an input image and a flat field image, pmFlatField shall divide the input image by the flat
    4  *  field image.
    5  *
    6  *  The input image, in, and the flat field image, flat, need not be the same size, since the input image may
    7  *  already have been trimmed (following overscan subtraction), but the function shall use the offsets in the
    8  *  image (in->x0 and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat
    9  *  field. In the event that the flat image is too small (i.e., pixels on the input image refer to pixels
    10  *  outside the range of the flat image), the function shall generate an error. Pixels which are negative or
    11  *  zero in the flat shall be masked in the input image with the value PM_MASK_FLAT. Negative pixels in the
    12  *  flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat
    13  *  shall be masked with corresponding values in the output. The function shall not normalize the flat; this
    14  *  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 from
    16  *  the flat to the output.
    17  *
    18  *  @author Ross Harman, MHPCC
    19  *
    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 Hawaii
    24  */
    25 
    261#if HAVE_CONFIG_H
    272#include <config.h>
     
    294
    305#include <stdio.h>
    31 #include <math.h>
    32 #include <strings.h>
     6#include <pslib.h>
    337
    34 #include <pslib.h>
    358#include "pmFPA.h"
    369#include "pmFlatField.h"
    3710#include "pmFPAMaskWeight.h"
    38 #include "pmFlatFieldErrors.h"
    3911
    4012
     
    5224    }
    5325    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    }
    5430
    5531    psImage *inImage   = in->image;     // Input image
    5632    psImage *inMask    = in->mask;      // Mask for input image
    5733    psImage *flatImage = flat->image;   // Flat-field image
     34    psImage *flatMask  = flat->mask;    // Mask for flat-field image
    5835
    5936    // Check input image is not larger than flat image; mask is the same size as the input
     
    7148
    7249    // 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;
    7552
    7653    // Check that offsets are within image limits
     
    8865    for (int j = 0; j < inImage->numRows; j++) { \
    8966        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])) { \
    9169                if (inMask) { \
    9270                    inMask->data.U8[j][i] |= PM_MASK_FLAT; \
     
    9472                inImage->data.TYPE[j][i] = SPECIAL; \
    9573            } else { \
    96                 inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i]; \
     74                inImage->data.TYPE[j][i] /= flatValue; \
    9775            } \
    9876        } \
     
    11290        FLAT_DIVISION_CASE(F64, NAN);
    11391    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);
    11594        return false;
    11695    }
Note: See TracChangeset for help on using the changeset viewer.