IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12745 for trunk/psLib


Ignore:
Timestamp:
Apr 4, 2007, 2:17:29 PM (19 years ago)
Author:
Paul Price
Message:

psImageShiftKernel is redundant now, with psImageShift calling psImageInterpolate.

Location:
trunk/psLib/src/imageops
Files:
2 edited

Legend:

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

    r12741 r12745  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2007-04-04 22:42:02 $
     12 *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2007-04-05 00:17:29 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    568568}
    569569
    570 // XXX this function seems to work (except for edge pixels and masked pixels
    571 // but the function below does not define the right 3x3 kernels.  look this
    572 // up
    573 psImage *p_psImageShiftKernel_F32(
    574     psImage *out,
    575     const psImage *input,
    576     const psImage *kernel)
    577 {
    578 
    579     PS_ASSERT_IMAGE_NON_NULL(input, NULL);
    580     PS_ASSERT_IMAGE_NON_NULL(kernel, NULL);
    581 
    582     if ((kernel->numCols % 2 == 0) || (kernel->numRows % 2 == 0)) {
    583         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    584                 _("kernel must have odd dimensions"));
    585         return NULL;
    586     }
    587     int Xk = (kernel->numCols - 1) / 2;
    588     int Yk = (kernel->numRows - 1) / 2;
    589 
    590     int outRows = input->numRows;
    591     int outCols = input->numCols;
    592     out = psImageRecycle(out, outCols, outRows, input->type.type);
    593     psImageInit (out, 0.0);
    594 
    595     // need to handle the edge cases...
    596     for (int row = 1; row < outRows-1; row++) {
    597         psF32 *outRow = out->data.F32[row];
    598         psF32 **inValue = input->data.F32;
    599         for (int col = 1; col < outCols-1; col++) {
    600             double value = 0;
    601             double norm = 0;
    602             psF32 **kernValue = kernel->data.F32;
    603             for (int yi = -Yk; yi <= Yk; yi++) {
    604                 for (int xi = -Xk; xi <= Xk; xi++) {
    605                     value += inValue[row+yi][col+xi]*kernValue[yi+Yk][xi+Xk];
    606                     norm += kernValue[yi+Yk][xi+Xk];
    607                 }
    608             }
    609             // include the mask tests and divide-by-zero test
    610             outRow[col] = value / norm;
    611         }
    612     }
    613 
    614     return (out);
    615 }
    616 
    617 // XXX fix the definition of the interpolation kernels and add integer shifts
    618 psImage *psImageShiftKernel (
    619     psImage *out,
    620     const psImage *input,
    621     float dx, float dy, psImageInterpolateMode mode)
    622 {
    623 
    624     psImage *kernel = NULL;
    625 
    626     switch (mode) {
    627     case PS_INTERPOLATE_BICUBE:
    628         kernel = psImageAlloc (3, 3, PS_TYPE_F32);
    629         for (int iy = -1; iy <= +1; iy++) {
    630             for (int ix = -1; ix <= +1; ix++) {
    631                 kernel->data.F32[iy+1][ix+1] = 5 - 3*PS_SQR(ix+dx) - 3*PS_SQR(iy+dy);
    632             }
    633         }
    634         out = p_psImageShiftKernel_F32 (out, input, kernel);
    635         break;
    636 
    637     case PS_INTERPOLATE_GAUSS:
    638         kernel = psImageAlloc (3, 3, PS_TYPE_F32);
    639         for (int iy = -1; iy <= +1; iy++) {
    640             for (int ix = -1; ix <= +1; ix++) {
    641                 kernel->data.F32[iy+1][ix+1] = exp(-0.5*PS_SQR(ix+dx) -0.5*PS_SQR(iy+dy));
    642             }
    643         }
    644         out = p_psImageShiftKernel_F32 (out, input, kernel);
    645         break;
    646 
    647     default:
    648         psError(PS_ERR_BAD_PARAMETER_NULL, true,
    649                 _("shift kernel for %d not defined"), mode);
    650         return NULL;
    651     }
    652     psFree (kernel);
    653     return (out);
    654 }
    655 
    656570psImage* psImageShift(psImage* out,
    657571                      const psImage* input,
  • trunk/psLib/src/imageops/psImageGeomManip.h

    r12741 r12745  
    66 * @author Robert DeSonia, MHPCC
    77 *
    8  * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-04-04 22:42:02 $
     8 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-04-05 00:17:29 $
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    9898);
    9999
    100 /** Shift image by an arbitrary number of pixels (dx,dy) in either direction.
    101  *
    102  *  If the shift values are fractional, the output pixel values should
    103  *  interpolate between the input pixel values. The output image has the same
    104  *  dimensions as the input image. Pixels which fall off the edge of the
    105  *  output image are lost. Newly exposed pixels are set to the value given by
    106  *  exposed. This function must be defined for the following types: psU8,
    107  *  psU16, psS8, psS16, psF32, psF64.
    108  *
    109  *  This implementation uses a NxN kernel generated based on the interpolation method
    110  *  the image is first shifted by a fractional amount with the kernel, then
    111  *  shifted in place by an integer amount.
    112  *
    113  *  XXX the integer shift portion is not implemented
    114  *  XXX the exposed pixels are not properly replaced
    115  *  XXX the algorithm can properly handle a mask, but the API does not include
    116  *  it (and it is not implemented)
    117  *
    118  *  @return psImage*     the shifted image result.
    119  */
    120 psImage* psImageShiftKernel(
    121     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
    122     const psImage* input,              ///< input image
    123     float dx,                          ///< the shift in x direction.
    124     float dy,                          ///< the shift in y direction.
    125     psImageInterpolateMode mode        ///< the interpolation mode to use
    126 );
    127 
    128 // XXX should this be global private or local static?
    129 psImage *p_psImageShiftKernel_F32(
    130     psImage *out,
    131     const psImage *input,
    132     const psImage *kernel);
    133 
    134100/** Roll image by an integer number of pixels in either direction.
    135101 *
Note: See TracChangeset for help on using the changeset viewer.