IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25453


Ignore:
Timestamp:
Sep 20, 2009, 10:06:38 AM (17 years ago)
Author:
eugene
Message:

more psImageMapCleanup to psLib

File:
1 edited

Legend:

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

    r23989 r25453  
    386386    return result;
    387387}
     388
     389bool psImageMapCleanup (psImageMap *map) {
     390
     391    if ((map->map->numRows == 1) && (map->map->numCols == 1)) return true;
     392
     393    // find the weighted average of all pixels
     394    float Sum = 0.0;
     395    float Wt = 0.0;
     396    for (int j = 0; j < map->map->numRows; j++) {
     397        for (int i = 0; i < map->map->numCols; i++) {
     398            if (!isfinite(map->map->data.F32[j][i])) continue;
     399            Sum += map->map->data.F32[j][i] * map->error->data.F32[j][i];
     400            Wt += map->error->data.F32[j][i];
     401        }
     402    }
     403
     404    float Mean = Sum / Wt;
     405
     406    // do any of the pixels in the map need to be repaired?
     407    // XXX for now, we are just replacing bad pixels with the Mean
     408    for (int j = 0; j < map->map->numRows; j++) {
     409        for (int i = 0; i < map->map->numCols; i++) {
     410            if (isfinite(map->map->data.F32[j][i]) &&
     411                (map->error->data.F32[j][i] > 0.0)) continue;
     412            map->map->data.F32[j][i] = Mean;
     413        }
     414    }
     415    return true;
     416}
     417
Note: See TracChangeset for help on using the changeset viewer.