IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 22, 2004, 10:02:57 AM (22 years ago)
Author:
desonia
Message:

Added psImageResample and complex support for pixel interpolation routines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageManip.c

    r1250 r1260  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-07-21 23:39:10 $
     12 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-07-22 20:02:56 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    404404    if (in == NULL) {
    405405        psError(__func__,"Input image is NULL.");
     406        psFree(out);
    406407        return NULL;
    407408    }
     
    409410    if (scale < 1) {
    410411        psError(__func__,"The scale must be positive.");
     412        psFree(out);
    411413        return NULL;
    412414    }
     
    414416    if (stats == NULL) {
    415417        psError(__func__,"The stats input can not be NULL.");
     418        psFree(out);
    416419        return NULL;
    417420    }
     
    419422    if (getSpecifiedStatValue(stats,&statVal) == false) {
    420423        psError(__func__,"The stat options didn't specify a single supported statistic type.");
     424        psFree(out);
    421425        return NULL;
    422426    }
     
    484488    return out;
    485489}
     490psImage* psImageResample(psImage* out, const psImage* in, int scale, psImageInterpolateMode mode)
     491{
     492    int outRows;
     493    int outCols;
     494    float invScale;
     495
     496    if (in == NULL) {
     497        psError(__func__,"Input image can not be NULL.");
     498        psFree(out);
     499        return NULL;
     500    }
     501
     502    // create an output image of the same size and type
     503    outRows = in->numRows*scale;
     504    outCols = in->numCols*scale;
     505    invScale = 1.0f / (float)scale;
     506
     507
     508    #define PSIMAGE_RESAMPLE_CASE(TYPE) \
     509case PS_TYPE_##TYPE: { \
     510        out = psImageRecycle(out,outCols, outRows, PS_TYPE_##TYPE); \
     511        for (int row=0;row<outRows;row++) { \
     512            ps##TYPE* rowData = out->data.TYPE[row]; \
     513            float inRow = (float)row * invScale; \
     514            for (int col=0;col<outCols;col++) { \
     515                rowData[col] = psImagePixelInterpolate(in,inRow,(float)col*invScale,0,mode); \
     516            } \
     517        }  \
     518        break; \
     519    }
     520
     521    switch(in->type.type) {
     522        PSIMAGE_RESAMPLE_CASE(U8)
     523        PSIMAGE_RESAMPLE_CASE(U16)
     524        PSIMAGE_RESAMPLE_CASE(U32)
     525        PSIMAGE_RESAMPLE_CASE(U64)
     526        PSIMAGE_RESAMPLE_CASE(S8)
     527        PSIMAGE_RESAMPLE_CASE(S16)
     528        PSIMAGE_RESAMPLE_CASE(S32)
     529        PSIMAGE_RESAMPLE_CASE(S64)
     530        PSIMAGE_RESAMPLE_CASE(F32)
     531        PSIMAGE_RESAMPLE_CASE(F64)
     532        PSIMAGE_RESAMPLE_CASE(C32)
     533        PSIMAGE_RESAMPLE_CASE(C64)
     534    default:
     535        psError(__func__,"Unsupported type (%d)",in->type.type);
     536        psFree(out);
     537        return NULL;
     538    }
     539
     540    return out;
     541}
    486542
    487543psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy)
     
    493549    if (in == NULL) {
    494550        psError(__func__,"Input image can not be NULL.");
     551        psFree(out);
    495552        return NULL;
    496553    }
     
    793850            PSIMAGE_ROTATE_ARBITRARY_LOOP(F64,MODE); \
    794851            break; \
     852        case PS_TYPE_C32: \
     853            PSIMAGE_ROTATE_ARBITRARY_LOOP(C32,MODE); \
     854            break; \
     855        case PS_TYPE_C64: \
     856            PSIMAGE_ROTATE_ARBITRARY_LOOP(C64,MODE); \
     857            break; \
    795858        default: \
    796859            psError(__func__,"Image type (%d) not supported",type); \
Note: See TracChangeset for help on using the changeset viewer.