- Timestamp:
- Sep 1, 2007, 4:03:58 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/imageops/psImageMap.c
r14721 r14723 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-09-0 1 00:41:01$9 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-02 02:03:58 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 22 22 #include "psAssert.h" 23 23 #include "psRegion.h" 24 #include "psVector.h" 24 25 #include "psImage.h" 26 #include "psStats.h" 25 27 #include "psImageBinning.h" 26 28 #include "psImageMap.h" 29 #include "psImagePixelInterpolate.h" 27 30 28 31 static void psImageMapFree(psImageMap *map) { … … 57 60 58 61 // 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; 62 bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) { 63 63 64 64 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK); … … 84 84 } 85 85 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++) { 88 90 89 91 // select the vector 90 92 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 92 97 // get the value 93 if (psVectorStats ( stats, vector, NULL, NULL, 0)) {98 if (psVectorStats (map->stats, vector, NULL, NULL, 0)) { 94 99 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); 96 102 } else { 97 103 mask->data.U8[iy][ix] = 1; … … 102 108 psImage *state = psImagePixelInterpolateState (&map->nBad, &map->nPoor, mask, 0xff); 103 109 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; 106 112 } 107 113
Note:
See TracChangeset
for help on using the changeset viewer.
