IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 2, 2014, 10:08:17 AM (12 years ago)
Author:
eugene
Message:

apply col0,row0 to psImageUnbin

File:
1 edited

Legend:

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

    r24497 r36631  
    3939    int DX = binning->nXbin;
    4040    int DY = binning->nYbin;
    41     int dx = binning->nXskip;
    42     int dy = binning->nYskip;
     41    // int dx = binning->nXskip;
     42    // int dy = binning->nYskip;
    4343
    4444    PS_ASSERT_INT_POSITIVE(DX, NULL);
    4545    PS_ASSERT_INT_POSITIVE(DY, NULL);
    46     PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dx, DX, NULL);
    47     PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dy, DY, NULL);
     46    // PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dx, DX, NULL);
     47    // PS_ASSERT_INT_LESS_THAN_OR_EQUAL(dy, DY, NULL);
    4848
    4949    long nx = in->numCols;
     
    5757    psF32 **vOut = out->data.F32;
    5858
     59    int col0 = out->col0;
     60    int row0 = out->row0;
     61
    5962    // loop over all input pixels excluding the last
    6063    for (int Iy = 0; Iy < ny-1; Iy ++) {
     
    7073            // corresponding to (Ix,Iy), (Ix+1,Iy+1)
    7174            // XXX should this be "+ dx" and + dy?
    72             int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5)));
    73             int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5)));
     75            // Ix,Iy are in input pixels coords; result of GetFine is in the
     76            // data space of the output, so we need to subtract col0,row0 to get raw pixels
     77            int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5) - col0));
     78            int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5) - row0));
    7479            int Xe = PS_MAX (0, PS_MIN (Nx, Xs + DX));
    7580            int Ye = PS_MAX (0, PS_MIN (Ny, Ys + DY));
     81            // fprintf (stderr, "%f, %f, %f, %f : %d, %d : %d - %d, %d - %d\n", V00, V01, V10, V11, Ix, Iy, Xs, Xe, Ys, Ye);
    7682
    7783            for (int iy = Ys; (iy < Ye) && (iy < Ny); iy++) {
     
    113119
    114120    // side pixels
    115     int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0  + 0.5)));
    116     int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5)));
     121    int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0  + 0.5) - col0));
     122    int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5) - col0));
    117123    for (int Iy = 0; Iy < ny - 1; Iy++) {
    118124
    119         int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5)));
     125        int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, Iy + 0.5) - row0));
    120126        int Ye = PS_MAX (0, PS_MIN (Ny, Ys + DY));
    121127
     
    148154
    149155    // top and bottom pixels
    150     int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0  + 0.5)));
    151     int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5)));
     156    int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0  + 0.5) - row0));
     157    int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5) - row0));
    152158    for (int Ix = 0; Ix < nx - 1; Ix++) {
    153159
    154         int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5)));
     160        int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, Ix + 0.5) - col0));
    155161        int Xe = PS_MAX (0, PS_MIN (Nx, Xs + DX));
    156162
     
    187193        float V;
    188194        // center of last pixel
    189         int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0  + 0.5)));
    190         int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5)));
    191         int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0  + 0.5)));
    192         int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5)));
     195        int Xs = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, 0  + 0.5) - col0));
     196        int Xe = PS_MAX (0, PS_MIN (Nx, psImageBinningGetFineX(binning, nx - 0.5) - col0));
     197        int Ys = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, 0  + 0.5) - row0));
     198        int Ye = PS_MAX (0, PS_MIN (Ny, psImageBinningGetFineY(binning, ny - 0.5) - row0));
    193199
    194200        // 0,0
Note: See TracChangeset for help on using the changeset viewer.