IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38267 for trunk/ppImage/src


Ignore:
Timestamp:
May 13, 2015, 11:11:15 AM (11 years ago)
Author:
eugene
Message:

ensure there are no NANs in the image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageSquashNANs.c

    r38233 r38267  
    44
    55#include "ppImage.h"
     6
     7# define LO_16BIT -32768
     8# define HI_16BIT  32768
     9# define MX_16BIT  65536
     10
     11bool ppImageSquashNANsImage (psImage *image, float minValue, float maxValue, float offset);
    612
    713bool ppImageSquashNANs(pmConfig *config, ppImageOptions *options, pmFPAview *view)
     
    1824
    1925    psImage *image = readout->image;    // Readout's image
     26
     27    // We are going to force the range to be (-999 to 2^16 - 1002, ie, 1 less on each end than 2^16. this allows for float round errors
     28    int bzero = LO_16BIT - 0;
     29    float minValue = HI_16BIT + bzero + 1;
     30    float maxValue = MX_16BIT + minValue - 3;
     31
     32    if (image->parent) {
     33        psImage *parent = (psImage *) image->parent;
     34        ppImageSquashNANsImage (parent, minValue, maxValue, 500.0);
     35    } else {
     36        ppImageSquashNANsImage (image, minValue, maxValue, 500.0);
     37
     38        // squash NANs in overscan regions
     39        psList *overscans = readout->bias; // List of the overscan images
     40        psListIterator *iter = psListIteratorAlloc(overscans, PS_LIST_HEAD, false); // Iterator
     41        psImage *overscan = NULL; // Overscan image from iterator
     42        while ((overscan = psListGetAndIncrement(iter))) {
     43            ppImageSquashNANsImage (overscan, minValue, maxValue, 500.0);
     44        }
     45        psFree(iter);
     46    }
     47
     48    psLogMsg ("ppImage", 5, "squash NANs: %f sec\n", psTimerMark ("squash.NANs"));
     49    return true;
     50}
     51
     52bool ppImageSquashNANsImage (psImage *image, float minValue, float maxValue, float offset) {
     53 
    2054    int numCols = image->numCols, numRows = image->numRows; // Size of image
    21 
     55 
    2256    for (int y = 0; y < numRows; y++) {
    2357        for (int x = 0; x < numCols; x++) {
    2458            if (!isfinite(image->data.F32[y][x])) {
    25                 image->data.F32[y][x] = -500.0;
     59                image->data.F32[y][x] = 1.0;
     60            } else {
     61                image->data.F32[y][x] = PS_MAX (minValue, PS_MIN (maxValue, image->data.F32[y][x] + 500.0));
    2662            }
    2763        }
    2864    }
    29     psLogMsg ("ppImage", 5, "squash NANs: %f sec\n", psTimerMark ("squash.NANs"));
    30 
    3165    return true;
    3266}
     67
Note: See TracChangeset for help on using the changeset viewer.