IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11795


Ignore:
Timestamp:
Feb 14, 2007, 2:38:51 PM (19 years ago)
Author:
magnier
Message:

fixed counting to be consistent with dvoMakeCorrUnbin; this may break psphot (TBD)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageUnbin.c

    r11299 r11795  
    1111
    1212// interpolate from model to background (~bresenham linear interpolation)
    13 // XXX this code skips the initial pixels?
    14 // XXX this code may be off by 0.5,0.5 pixels
     13// DX, DY are the binning factor
     14// dx, dy is the distance is high-res pixels to the 0,0 corner of the first
     15// binned pixel.
     16// XXX check that this is still consistent with psphotImageMedian...
    1517psImage *psImageUnbin(psImage *out, const psImage *in, int DX, int DY, int dx, int dy)
    1618{
     
    3032    psF32 **vOut = out->data.F32;
    3133
    32     // loop over all pixels with
     34    // loop over all input pixels excluding the last
    3335    for (int Iy = 0; Iy < ny-1; Iy ++) {
    3436        for (int Ix = 0; Ix < nx-1; Ix ++) {
     
    126128        }
    127129    }
     130    // return out;
    128131
    129132    // the four corners
    130133    {
    131134        float V;
     135        // center of last pixel
     136        int Xs = PS_MAX (0, PS_MIN (Nx, ( 0 + 0.5)*DX - dx));
     137        int Xe = PS_MAX (0, PS_MIN (Nx, (nx - 0.5)*DX - dx));
     138        int Ys = PS_MAX (0, PS_MIN (Ny, ( 0 + 0.5)*DY - dy));
     139        int Ye = PS_MAX (0, PS_MIN (Ny, (ny - 0.5)*DY - dy));
     140
    132141        // 0,0
    133142        V = vIn[0][0];
    134         for (int iy = 0; iy < DY - dy; iy++)
    135         {
    136             for (int ix = 0; ix < DX - dx; ix++) {
     143        for (int iy = 0; iy < Ys; iy++)
     144        {
     145            for (int ix = 0; ix < Xs; ix++) {
    137146                vOut[iy][ix] = V;
    138147            }
     
    140149        // Nx,0
    141150        V = vIn[0][nx-1];
    142         for (int iy = 0; iy < DY - dy; iy++)
    143         {
    144             for (int ix = nx*DX - dx; ix < Nx; ix++) {
     151        for (int iy = 0; iy < Ys; iy++)
     152        {
     153            for (int ix = Xe; ix < Nx; ix++) {
    145154                vOut[iy][ix] = V;
    146155            }
     
    148157        // 0,Ny
    149158        V = vIn[ny-1][0];
    150         for (int iy = ny*DY - dy; iy < Ny; iy++)
    151         {
    152             for (int ix = 0; ix < DX - dx; ix++) {
     159        for (int iy = Ye; iy < Ny; iy++)
     160        {
     161            for (int ix = 0; ix < Xs; ix++) {
    153162                vOut[iy][ix] = V;
    154163            }
     
    156165        // Nx,Ny
    157166        V = vIn[ny-1][nx-1];
    158         for (int iy = ny*DY - dy; iy < Ny; iy++)
    159         {
    160             for (int ix = nx*DX - dx; ix < Nx; ix++) {
     167        for (int iy = Ye; iy < Ny; iy++)
     168        {
     169            for (int ix = Xe; ix < Nx; ix++) {
    161170                vOut[iy][ix] = V;
    162171            }
Note: See TracChangeset for help on using the changeset viewer.