IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 4, 2008, 9:51:09 PM (18 years ago)
Author:
Paul Price
Message:

Adding capability for a mask to be provided when determining BSCALE,BZERO. This is required for the case when a large masked region of the image has been set to a constant (or close to a constant). If the mask is not provided in this case, then the standard deviation is under-estimated, leading to a choice of BSCALE,BZERO that adversely affects the dynamic range of the image. Added functions psFitsWriteImageWithMask, psFitsUpdateImageWithMask and psFitsInsertImageWithMask, and kept the APIs of psFitsWriteImage, psFitsUpdateImage and psFitsInsertImage so that this change shouldn't break anything.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsScale.c

    r18156 r19383  
    1313#include "psTrace.h"
    1414
     15#include "psImage.h"
    1516#include "psFits.h"
    1617#include "psImageBackground.h"
     
    9899                       double *bzero, // Zero point, to return
    99100                       const psImage *image, // Image to scale
     101                       const psImage *mask, // Mask image
     102                       psMaskType maskVal, // Value to mask
    100103                       const psFitsOptions *options // FITS options
    101104    )
     
    112115    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed);
    113116    psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object
    114     if (!psImageBackground(stats, NULL, image, NULL, 0, rng)) {
     117    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) {
    115118        psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on image");
    116119        psFree(rng);
     
    163166//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    164167
    165 bool psFitsScaleDetermine(double *bscale, // Scaling, to return
    166                           double *bzero, // Zero point, to return
    167                           long *blank,  // Blank value, to return
    168                           const psImage *image, // Image to scale
    169                           const psFits *fits // FITS options
    170     )
     168bool psFitsScaleDetermine(double *bscale, double *bzero, long *blank, const psImage *image,
     169                          const psImage *mask, psMaskType maskVal, const psFits *fits)
    171170{
    172171    PS_ASSERT_PTR_NON_NULL(bscale, false);
     
    174173    PS_ASSERT_PTR_NON_NULL(blank, false);
    175174    PS_ASSERT_IMAGE_NON_NULL(image, false);
     175    if (mask) {
     176        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     177        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
     178    }
    176179    PS_ASSERT_FITS_NON_NULL(fits, false);
    177180
     
    216219      case PS_FITS_SCALE_STDEV_NEGATIVE:
    217220      case PS_FITS_SCALE_STDEV_BOTH:
    218         if (!scaleStdev(bscale, bzero, image, options)) {
     221        if (!scaleStdev(bscale, bzero, image, mask, maskVal, options)) {
    219222            psError(PS_ERR_UNKNOWN, false, "Unable to set BSCALE and BZERO from stdev");
    220223            return false;
Note: See TracChangeset for help on using the changeset viewer.