IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 1, 2007, 4:03:58 PM (19 years ago)
Author:
magnier
Message:

updates to the image map tools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070830/psLib/src/imageops/psImageMap.c

    r14721 r14723  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-01 00:41:01 $
     9 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-02 02:03:58 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    2222#include "psAssert.h"
    2323#include "psRegion.h"
     24#include "psVector.h"
    2425#include "psImage.h"
     26#include "psStats.h"
    2527#include "psImageBinning.h"
    2628#include "psImageMap.h"
     29#include "psImagePixelInterpolate.h"
    2730
    2831static void psImageMapFree(psImageMap *map) {
     
    5760
    5861// generate a psImageMap (or NULL) with the given number of superpixels in X and Y
    59 psImageMap *psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) {
    60 
    61     int nBad;
    62     int nPoor;
     62bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) {
    6363
    6464    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK);
     
    8484    }
    8585
    86     for (int iy = 0; iy < map->map->numRows; iy++) {
    87         for (int ix = 0; ix < map->map->numCols; ix++) {
     86    int Nx = map->map->numCols;
     87    int Ny = map->map->numRows;
     88    for (int iy = 0; iy < Ny; iy++) {
     89        for (int ix = 0; ix < Nx; ix++) {
    8890   
    8991            // select the vector
    9092            psVector *vector = vectors->data[ix + iy*Nx];
    91            
     93
     94            // reset the stats to avoid contamination from the previous loop
     95            psStatsInit (map->stats);
     96
    9297            // get the value
    93             if (psVectorStats (stats, vector, NULL, NULL, 0)) {
     98            if (psVectorStats (map->stats, vector, NULL, NULL, 0)) {
    9499                mask->data.U8[iy][ix] = 0;
    95                 map->map->data.F32[iy][ix] = stats->robustMedian; // XXX select correct stats
     100                // XXX ensure only one option is selected, or save both position and width
     101                map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
    96102            } else {
    97103                mask->data.U8[iy][ix] = 1;
     
    102108    psImage *state = psImagePixelInterpolateState (&map->nBad, &map->nPoor, mask, 0xff);
    103109    map->nGood = mask->numCols * mask->numRows - map->nBad - map->nPoor;
    104     if (nBad > badFrac * mask->numCols * mask->numRows) {
    105         return false:
     110    if (map->nBad > badFrac * mask->numCols * mask->numRows) {
     111        return false;
    106112    }
    107113
Note: See TracChangeset for help on using the changeset viewer.