IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 27, 2004, 9:49:54 AM (22 years ago)
Author:
desonia
Message:

Changed the unexposedValue for psImageRotate and psImageShift (bug #150). Also optimized psImageShift by using the inline private interpolation functions.

File:
1 edited

Legend:

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

    r1605 r1635  
    1 
    21/** @file  psImageManip.c
    32 *
     
    1110 *  @author Ross Harman, MHPCC
    1211 *
    13  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-08-20 02:55:58 $
     12 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-08-27 19:49:54 $
    1514 *
    1615 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1716 */
    18 #include <math.h>                          // for
    19 // isfinite(),
    20 // etc.
     17
     18#include <math.h>                          // for isfinite(), etc.
    2119#include <stdlib.h>
    2220#include <stdbool.h>
    23 #include <string.h>                        // for
    24 // memcpy,
    25 // etc.
     21#include <string.h>                        // for memcpy, etc.
    2622
    2723#include "psError.h"
     
    594590                       const psImage* in,
    595591                       float angle,
    596                        float unexposedValue,
     592                       psC64 unexposedValue,
    597593                       psImageInterpolateMode mode)
    598594{
     
    764760
    765761        #define PSIMAGE_ROTATE_ARBITRARY_LOOP(TYPE,MODE) { \
    766             if (unexposedValue < PS_MIN_##TYPE || unexposedValue > PS_MAX_##TYPE) { \
    767                 psError(__func__,"The given unexposedValue (%g) is outside of the " \
     762            if (creal(unexposedValue) < PS_MIN_##TYPE || creal(unexposedValue) > PS_MAX_##TYPE || \
     763                    cimag(unexposedValue) < PS_MIN_##TYPE || cimag(unexposedValue) > PS_MAX_##TYPE) { \
     764                psError(__func__,"The given unexposedValue (%g%+g) is outside of the " \
    768765                        "image type's range (%g->%g).", \
    769                         unexposedValue, (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
     766                        creal(unexposedValue),cimag(unexposedValue), \
     767                        (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
    770768                psFree(out); \
    771769                out = NULL; \
     
    850848                      float dx,
    851849                      float dy,
    852                       psF64 unexposedValue,
     850                      psC64 unexposedValue,
    853851                      psImageInterpolateMode mode)
    854852{
     
    870868    out = psImageRecycle(out, outCols, outRows, type);
    871869
    872     #define PSIMAGE_SHIFT_CASE(TYPE) \
     870    #define PSIMAGE_SHIFT_CASE(MODE,TYPE) \
    873871case PS_TYPE_##TYPE: \
    874     if (unexposedValue < PS_MIN_##TYPE || unexposedValue > PS_MAX_##TYPE) { \
    875         psError(__func__,"The given unexposedValue (%g) is outside of the " \
     872    if (creal(unexposedValue) < PS_MIN_##TYPE || creal(unexposedValue) > PS_MAX_##TYPE || \
     873            cimag(unexposedValue) < PS_MIN_##TYPE || cimag(unexposedValue) > PS_MAX_##TYPE) { \
     874        psError(__func__,"The given unexposedValue (%g%+g) is outside of the " \
    876875                "image type's range (%g->%g).", \
    877                 unexposedValue, (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
     876                creal(unexposedValue), cimag(unexposedValue), \
     877                (double)PS_MIN_##TYPE,(double)PS_MAX_##TYPE); \
    878878        psFree(out); \
    879879        out = NULL; \
     
    884884        float y = dy+(float)row; \
    885885        for (int col=0;col<outCols;col++) { \
    886             outRow[col] = psImagePixelInterpolate(in,dx+(float)col,y,unexposedValue,mode); \
     886            outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE(in,dx+(float)col,y,unexposedValue); \
    887887        } \
    888888    } \
    889889    break;
    890890
    891     switch (in->type.type) {
    892         PSIMAGE_SHIFT_CASE(U8);
    893         PSIMAGE_SHIFT_CASE(U16);
    894         PSIMAGE_SHIFT_CASE(U32);
    895         PSIMAGE_SHIFT_CASE(U64);
    896         PSIMAGE_SHIFT_CASE(S8);
    897         PSIMAGE_SHIFT_CASE(S16);
    898         PSIMAGE_SHIFT_CASE(S32);
    899         PSIMAGE_SHIFT_CASE(S64);
    900         PSIMAGE_SHIFT_CASE(F32);
    901         PSIMAGE_SHIFT_CASE(F64);
    902         PSIMAGE_SHIFT_CASE(C32);
    903         PSIMAGE_SHIFT_CASE(C64);
     891    #define PSIMAGE_SHIFT_ARBITRARY_CASE(MODE) \
     892case PS_INTERPOLATE_##MODE: \
     893    switch (in->type.type) { \
     894        PSIMAGE_SHIFT_CASE(MODE,U8); \
     895        PSIMAGE_SHIFT_CASE(MODE,U16); \
     896        PSIMAGE_SHIFT_CASE(MODE,U32); \
     897        PSIMAGE_SHIFT_CASE(MODE,U64); \
     898        PSIMAGE_SHIFT_CASE(MODE,S8); \
     899        PSIMAGE_SHIFT_CASE(MODE,S16); \
     900        PSIMAGE_SHIFT_CASE(MODE,S32); \
     901        PSIMAGE_SHIFT_CASE(MODE,S64); \
     902        PSIMAGE_SHIFT_CASE(MODE,F32); \
     903        PSIMAGE_SHIFT_CASE(MODE,F64); \
     904        PSIMAGE_SHIFT_CASE(MODE,C32); \
     905        PSIMAGE_SHIFT_CASE(MODE,C64); \
     906    default: \
     907        psError(__func__, "Image type (%d) not supported.", type); \
     908        psFree(out); \
     909        out = NULL; \
     910    }
     911
     912    switch (mode) {
     913        PSIMAGE_SHIFT_ARBITRARY_CASE(FLAT);
     914        PSIMAGE_SHIFT_ARBITRARY_CASE(BILINEAR);
    904915    default:
    905         psError(__func__, "Image type (%d) not supported.", type);
     916        psError(__func__, "Unsupported interpolation mode (%d)", mode);
    906917        psFree(out);
    907918        out = NULL;
    908919    }
     920
    909921    return out;
    910922}
Note: See TracChangeset for help on using the changeset viewer.