IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 3, 2007, 10:29:07 AM (19 years ago)
Author:
magnier
Message:

updates to image map code, tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070830/psLib/test/imageops/tap_psImageMap.c

    r14725 r14726  
    9292
    9393    // make a model for a well-sampled field of a non-polynomial function (f = (a(x-xo)^2 + b(y-yo)^2)^-1)
     94    {
     95        // function is defined over the range 0-1000, 0-1000
     96        psImageBinning *binning = psImageBinningAlloc();
     97        binning->nXfine = 1000;
     98        binning->nYfine = 1000;
     99        binning->nXruff = 5;
     100        binning->nYruff = 5;
     101
     102        // generate a grid of test data points
     103        psVector *x = psVectorAllocEmpty (100, PS_TYPE_F32);
     104        psVector *y = psVectorAllocEmpty (100, PS_TYPE_F32);
     105        psVector *f = psVectorAllocEmpty (100, PS_TYPE_F32);
     106
     107        for (int ix = 0; ix < 1000; ix += 10) {
     108            for (int iy = 0; iy < 1000; iy += 10) {
     109                x->data.F32[x->n] = ix;
     110                y->data.F32[y->n] = iy;
     111                f->data.F32[f->n] = C00 / (C10*PS_SQR(ix-500) + C01*PS_SQR(iy-500) + 0.1);
     112                psVectorExtend (x, 100, 1);
     113                psVectorExtend (y, 100, 1);
     114                psVectorExtend (f, 100, 1);
     115            }
     116        }
     117
     118        psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
     119
     120        // scale defines both field and map image sizes (nXfine, nXruff)
     121        psImageMap *map = psImageMapAlloc (NULL, binning, stats);
     122
     123        // allocate a map, but we have no field image to supply
     124        // XXX this function needs to correct for the mean superpixel position
     125        // which is sampled...
     126        psImageMapGenerate (map, x, y, f, 0.1);
     127        psFree (binning);
     128
     129        fprintf (stderr, "nGood: %d\n", map->nGood);
     130        fprintf (stderr, "nPoor: %d\n", map->nPoor);
     131        fprintf (stderr, "nBad:  %d\n", map->nBad);
     132       
     133        SaveImage (NULL, map->map, "map.fits");
     134       
     135        psImage *field = psImageAlloc(1000, 1000, PS_TYPE_F32);
     136        for (int ix = 0; ix < 1000; ix++) {
     137            for (int iy = 0; iy < 1000; iy++) {
     138                field->data.F32[iy][ix] = C00 / (C10*PS_SQR(ix-500) + C01*PS_SQR(iy-500) + 0.1);
     139            }
     140        }
     141        SaveImage (NULL, field, "field.fits");
     142
     143        // measure difference between model (map) and data (field)
     144        for (int ix = 0; ix < map->map->numCols; ix++) {
     145            for (int iy = 0; iy < map->map->numRows; iy++) {
     146             
     147                int xo = (ix + 0.5)*map->binning->nXbin;
     148                int yo = (iy + 0.5)*map->binning->nYbin;
     149                float df = field->data.F32[yo][xo] - map->map->data.F32[iy][ix];
     150                fprintf (stderr, "%d %d -> %d %d  :  %f = %f - %f\n", ix, iy, xo, yo, df, field->data.F32[yo][xo], map->map->data.F32[iy][ix]);
     151            }
     152        }
     153    }
    94154
    95155    // make a model for a poorly-sampled field of a non-polynomial function (f = (a(x-xo)^2 + b(y-yo)^2)^-1)
Note: See TracChangeset for help on using the changeset viewer.