IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 26, 2007, 4:43:22 PM (19 years ago)
Author:
magnier
Message:

created a common set of routines to define the binning parameters

File:
1 edited

Legend:

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

    r11795 r12588  
     1/** @file  psImageUnbin.c
     2 *
     3 *  @brief Functions to perform unbinning (resampling) of images.
     4 *
     5 *  @ingroup Image
     6 *
     7 *  @author Eugene Magnier, IfA
     8 *
     9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-03-27 02:43:22 $
     11 *
     12 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     13 */
     14
    115#ifdef HAVE_CONFIG_H
    216# include "config.h"
     
    418
    519#include <stdio.h>
    6 
    720#include "psError.h"
     21#include "psAssert.h"
     22#include "psRegion.h"
    823#include "psImage.h"
    9 #include "psAssert.h"
     24#include "psImageBinning.h"
    1025#include "psImageUnbin.h"
    1126
     
    1530// binned pixel.
    1631// XXX check that this is still consistent with psphotImageMedian...
    17 psImage *psImageUnbin(psImage *out, const psImage *in, int DX, int DY, int dx, int dy)
     32psImage *psImageUnbin(psImage *out, const psImage *in, const psImageBinning *binning)
    1833{
    1934    PS_ASSERT_IMAGE_NON_NULL(in, NULL);
    2035    PS_ASSERT_IMAGE_NON_NULL(out, NULL);
     36
     37    int DX = binning->nXbin;
     38    int DY = binning->nYbin;
     39    int dx = binning->nXskip;
     40    int dy = binning->nYskip;
     41
    2142    PS_ASSERT_INT_POSITIVE(DX, NULL);
    2243    PS_ASSERT_INT_POSITIVE(DY, NULL);
     
    2849    long Nx = out->numCols;
    2950    long Ny = out->numRows;
     51
     52    // XXX validate the binning structure vs the input and output images?
    3053
    3154    psF32 **vIn = in->data.F32;
     
    183206 * cases should be added
    184207 */
    185 double psImageUnbinPixel(const int ix, const int iy, // desired Unbinned point
     208double psImageUnbinPixel(const int ix, const int iy, // desired Unbinned point (parent coords)
    186209                         const psImage *in, // binned image
    187                          const int DX, const int DY,  //!< Scaling factors in x and y
    188                          const int dx, const int dy)   //!< Overhang
     210                         const psImageBinning *binning)   //!< Overhang
    189211{
     212
     213    int DX = binning->nXbin;
     214    int DY = binning->nYbin;
     215    int dx = binning->nXskip;
     216    int dy = binning->nYskip;
     217
    190218    PS_ASSERT_IMAGE_NON_NULL(in, NAN);
    191219    assert (in->type.type == PS_TYPE_F32);
     220
    192221    PS_ASSERT_INT_POSITIVE(DX, NAN);
    193222    PS_ASSERT_INT_POSITIVE(DY, NAN);
     
    197226     * Find which binned pixel we're in
    198227     */
    199     const int Xs = (ix + dx)/DX; // index of binned pixel
    200     const int Ys = (iy + dy)/DY;
     228
     229    const int Xs = (ix - dx)/DX; // index of binned pixel
     230    const int Ys = (iy - dy)/DY;
    201231    if (Xs < 0 || Xs >= in->numCols || Ys < 0 || Ys >= in->numRows) {
    202232        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Point (%d,%d) lies outside binned image", ix, iy);
Note: See TracChangeset for help on using the changeset viewer.