IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7380


Ignore:
Timestamp:
Jun 6, 2006, 5:22:07 PM (20 years ago)
Author:
Paul Price
Message:

Merging the pslib "additional" functions from the modules into psLib proper.

Added jpeg directory for psImageJpeg.
Changes to build system (configure.ac, and various Makefile.am)

psVectorSmooth: changed API to allow optional output vector
psSparse: changed sizes to type "long"; added "const"
psRegionIsBad: Renamed psRegionIsNaN
psImageBicubeFit: changed sizes to "long"; added a "const"
psLine: changed sizes to "long"
psImageUnbin: description required in SDRS
psImageClippedStats: renaming to psImageBackground; removing static structures; API changed!
psImageFlipX, psImageFlipY merged to psImageFlip
psStringSubstitute: added "const"

Location:
trunk/psLib
Files:
24 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/configure.ac

    r7300 r7380  
    2626
    2727SRCPATH='${top_srcdir}/src'
    28 SRCDIRS="sys astro db fft fits imageops math mathtypes types xml"
     28SRCDIRS="sys astro db fft fits imageops jpeg math mathtypes types xml"
    2929# escape two escapes at this level so \\ gets passed to the shell and \ to perl
    3030SRCINC=`echo "${SRCDIRS=}" | ${PERL} -pe "s|(\w+)|-I\\\\${SRCPATH=}/\1|g"`
     
    241241AC_SUBST([GSL_CFLAGS])
    242242
     243dnl libjpeg -------------------------------------------------------------------
     244
     245AC_CHECK_LIB(jpeg,jpeg_CreateCompress,[],[AC_MSG_ERROR([jpeg library not found.])])
     246
    243247dnl ------------------- XML2 options ---------------------
    244248AC_ARG_WITH(xml2-config,
     
    316320AM_CONDITIONAL(DOXYGEN, test x$doxygen = xtrue)
    317321
    318 
    319322dnl ------- restore CFLAGS / LDFLAGS (tests done) --------
    320323CFLAGS="${CFLAGS} -Wall -Werror"
     
    338341  src/fits/Makefile
    339342  src/imageops/Makefile
     343  src/jpeg/Makefile
    340344  src/math/Makefile
    341345  src/mathtypes/Makefile
     
    349353  test/fits/Makefile
    350354  test/imageops/Makefile
     355  test/jpeg/Makefile
    351356  test/math/Makefile
    352357  test/mathtypes/Makefile
  • trunk/psLib/src/imageops/Makefile.am

    r7210 r7380  
    55libpslibimageops_la_CPPFLAGS = $(SRCINC)
    66libpslibimageops_la_SOURCES = \
     7        psImageBackground.c \
    78        psImageConvolve.c \
    89        psImageGeomManip.c \
     
    1112        psImageStats.c \
    1213        psImageStructManip.c \
    13     psImageMaskOps.c
     14        psImageMaskOps.c \
     15        psImageUnbin.c
    1416
    1517EXTRA_DIST = imageops.i
     
    1719pslibincludedir = $(includedir)
    1820pslibinclude_HEADERS = \
     21        psImageBackground.h \
    1922        psImageConvolve.h \
    2023        psImageGeomManip.h \
     
    2326        psImageStats.h \
    2427        psImageStructManip.h \
    25     psImageMaskOps.h
     28        psImageMaskOps.h \
     29        psImageUnbin.h
    2630
    2731CLEANFILES = *~
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r6806 r7380  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-04-06 22:55:18 $
     12 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-06-07 03:22:06 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psImageGeomManip.h"
    2424
     25#include "psAbort.h"
    2526#include "psError.h"
    2627#include "psImage.h"
     
    878879}
    879880
     881
     882#define FLIP_X_CASE(TYPENAME,TYPE) \
     883case TYPENAME: { \
     884    long numRows = input->numRows; \
     885    long numCols = input->numCols; \
     886    for (long i = 0; i < numRows; i++) { \
     887        for (long j = 0; j < numCols; j++) { \
     888            output->data.TYPE[i][j] = input->data.TYPE[i][numCols - j - 1]; \
     889        } \
     890    } \
     891    break; \
     892}
     893
     894#define FLIP_Y_CASE(TYPENAME,TYPE) \
     895case TYPENAME: { \
     896    long numRows = input->numRows; \
     897    long numCols = input->numCols; \
     898    for (long i = 0; i < numRows; i++) { \
     899        for (long j = 0; j < numCols; j++) { \
     900            output->data.TYPE[i][j] = input->data.TYPE[numRows - i - 1][j]; \
     901        } \
     902    } \
     903    break; \
     904}
     905
     906psImage *psImageFlip(psImage *output, const psImage *input, bool xFlip, bool yFlip)
     907{
     908    PS_ASSERT_IMAGE_NON_NULL(input, NULL);
     909
     910    if (xFlip && yFlip) {
     911        // This is equivalent to a 180 degree rotation;
     912        return psImageRotate(output, input, M_PI, NAN, PS_INTERPOLATE_BILINEAR);
     913    }
     914
     915    if (!xFlip && !yFlip) {
     916        // They want something, so let's give it to them
     917        return psImageCopy(output, input, input->type.type);
     918    }
     919
     920    output = psImageRecycle(output, input->numCols, input->numRows, input->type.type);
     921
     922    if (xFlip) {
     923        switch (input->type.type) {
     924            FLIP_X_CASE(PS_TYPE_U8,  U8);
     925            FLIP_X_CASE(PS_TYPE_U16, U16);
     926            FLIP_X_CASE(PS_TYPE_U32, U32);
     927            FLIP_X_CASE(PS_TYPE_U64, U64);
     928            FLIP_X_CASE(PS_TYPE_S8,  S8);
     929            FLIP_X_CASE(PS_TYPE_S16, S16);
     930            FLIP_X_CASE(PS_TYPE_S32, S32);
     931            FLIP_X_CASE(PS_TYPE_S64, S64);
     932            FLIP_X_CASE(PS_TYPE_F32, F32);
     933            FLIP_X_CASE(PS_TYPE_F64, F64);
     934            FLIP_X_CASE(PS_TYPE_C32, C32);
     935            FLIP_X_CASE(PS_TYPE_C64, C64);
     936        default:
     937            psFree(output);
     938            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown type for input image: %x\n", input->type.type);
     939            return NULL;
     940        }
     941        return output;
     942    }
     943    if (yFlip) {
     944        switch (input->type.type) {
     945            FLIP_Y_CASE(PS_TYPE_U8,  U8);
     946            FLIP_Y_CASE(PS_TYPE_U16, U16);
     947            FLIP_Y_CASE(PS_TYPE_U32, U32);
     948            FLIP_Y_CASE(PS_TYPE_U64, U64);
     949            FLIP_Y_CASE(PS_TYPE_S8,  S8);
     950            FLIP_Y_CASE(PS_TYPE_S16, S16);
     951            FLIP_Y_CASE(PS_TYPE_S32, S32);
     952            FLIP_Y_CASE(PS_TYPE_S64, S64);
     953            FLIP_Y_CASE(PS_TYPE_F32, F32);
     954            FLIP_Y_CASE(PS_TYPE_F64, F64);
     955            FLIP_Y_CASE(PS_TYPE_C32, C32);
     956            FLIP_Y_CASE(PS_TYPE_C64, C64);
     957        default:
     958            psFree(output);
     959            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown type for input image: %x\n", input->type.type);
     960            return NULL;
     961        }
     962        return output;
     963    }
     964
     965    psAbort(__func__, "Should never get here.\n");
     966    return NULL;
     967}
  • trunk/psLib/src/imageops/psImageGeomManip.h

    r6750 r7380  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-04-01 02:43:57 $
     10 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-06-07 03:22:06 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    151151    psRegion region,                   ///< the size of the transformed image
    152152    const psPixels* pixels,            /**< if not NULL, consists of psPixelCoords and specifies
    153                                             * which pixels in output image shall be transformed;
    154                                             * otherwise, entire image generated*/
     153                                                * which pixels in output image shall be transformed;
     154                                                * otherwise, entire image generated*/
    155155    psImageInterpolateMode mode,       ///< the interpolation scheme to be used
    156156    double exposedValue                ///< Exposed value to which non-corresponding pixels are set
    157157);
    158158
     159// Flip the input image
     160psImage *psImageFlip(psImage *output,   // Output image, or NULL
     161                     const psImage *input, // Input image
     162                     bool xFlip,        // Flip x axis?
     163                     bool yFlip         // Flip y axis?
     164                    );
     165
    159166#endif // #ifndef PS_IMAGE_GEOM_MANIP_H
  • trunk/psLib/src/imageops/psImagePixelManip.c

    r7123 r7380  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-05-16 03:27:13 $
     12 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-06-07 03:22:06 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    413413    return numClipped;
    414414}
    415 
  • trunk/psLib/src/math/Makefile.am

    r7210 r7380  
    88        psBinaryOp.c \
    99        psCompare.c \
     10        psEllipse.c \
    1011        psMatrix.c \
    1112        psMinimizeLMM.c \
    1213        psMinimizePowell.c \
    1314        psMinimizePolyFit.c \
     15        psPolynomial.c \
     16        psPolynomialUtils.c \
    1417        psRandom.c \
    1518        psRegion.c \
    1619        psRegionForImage.c \
    17         psPolynomial.c \
     20        psSparse.c \
    1821        psSpline.c \
    1922        psStats.c \
    20         psMathUtils.c
     23        psMathUtils.c \
     24        psVectorSmooth.c
    2125
    2226EXTRA_DIST = math.i
     
    2832        psCompare.h \
    2933        psConstants.h \
     34        psEllipse.h \
    3035        psMatrix.h \
    3136        psMinimizeLMM.h \
    3237        psMinimizePowell.h \
    3338        psMinimizePolyFit.h \
     39        psPolynomial.h \
     40        psPolynomialUtils.h \
    3441        psRandom.h \
    3542        psRegion.h \
    3643        psRegionForImage.h \
    37         psPolynomial.h \
     44        psSparse.h \
    3845        psSpline.h \
    3946        psStats.h \
    40         psMathUtils.h
     47        psMathUtils.h \
     48        psVectorSmooth.h
    4149
    4250CLEANFILES = *~
  • trunk/psLib/src/math/psRegion.c

    r6874 r7380  
    8484}
    8585
     86bool inline psRegionIsNaN(const psRegion region)
     87{
     88    return isnan(region.x0) || isnan(region.x1) || isnan(region.y0) || isnan(region.y1);
     89}
     90
  • trunk/psLib/src/math/psRegion.h

    r6874 r7380  
    7070);
    7171
     72// Test if any element of the region is NaN
     73bool inline psRegionIsNaN(const psRegion region// Region to check
     74                         );
    7275
    7376#endif
  • trunk/psLib/src/pslib_strict.h

    r7211 r7380  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2006-05-25 21:19:45 $
     11*  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2006-06-07 03:22:06 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4242
    4343#include "psXML.h"
     44
    4445#include "psImageConvolve.h"
    4546#include "psImageGeomManip.h"
     
    4950#include "psImageStructManip.h"
    5051#include "psImageMaskOps.h"
     52#include "psImageUnbin.h"
     53
     54#include "psImageJpeg.h"
    5155
    5256#include "psBinaryOp.h"
     
    6165#include "psRegionForImage.h"
    6266#include "psPolynomial.h"
     67#include "psPolynomialUtils.h"
    6368#include "psSpline.h"
    6469#include "psStats.h"
     
    8489#include "psMetadata.h"
    8590#include "psMetadataConfig.h"
     91#include "psMetadataItemParse.h"
     92#include "psMetadataItemCompare.h"
    8693#include "psPixels.h"
    8794#include "psArguments.h"
     95#include "psVectorSmooth.h"
     96#include "psImageBackground.h"
     97#include "psEllipse.h"
     98#include "psSparse.h"
    8899
    89100#endif // #ifndef PS_LIB_STRICT_H
  • trunk/psLib/src/sys/Makefile.am

    r7210 r7380  
    99        psError.c      \
    1010        psErrorCodes.c \
     11        psLine.c       \
    1112        psLogMsg.c     \
    1213        psMemory.c     \
     
    3233        psError.h      \
    3334        psErrorCodes.h \
     35        psLine.h       \
    3436        psLogMsg.h     \
    3537        psMemory.h     \
  • trunk/psLib/src/sys/psString.c

    r7251 r7380  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-05-31 20:56:37 $
     15 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-06-07 03:22:06 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131psString psStringCopy(const char *string)
    3232{
    33     PS_ASSERT_PTR_NON_NULL(string, NULL);
     33    // Pass through NULL values!
     34
    3435    // Allocate memory using psAlloc function
    3536    // Copy input string to memory just allocated
    3637    // Return the copy
    37     // Pass through NULL values
    3838    return string ? strcpy(psAlloc(strlen(string) + 1), string) : NULL;
    3939}
     
    218218// given the input string, search for all copies of the key, and replace with the replacement value
    219219// the input string may be freed if not needed
    220 char *psStringSubstitute (char *input, char *replace, char *key)
    221 {
    222 
    223     char *p;
    224 
    225     if (key == NULL)
     220char *psStringSubstitute(char *input, const char *replace, const char *key)
     221{
     222    if (key == NULL || strlen(key) == 0) {
    226223        return input;
    227     if (strlen(key) == 0)
    228         return input;
     224    }
    229225
    230226    while (true) {
    231         p = strstr (input, key);
    232         if (p == NULL)
     227        char *p = strstr (input, key);
     228        if (!p) {
    233229            return input;
     230        }
    234231
    235232        // we have input = xxxkeyxxx
     
    241238
    242239        // copy the first segement into 'output'
    243         strncpy (output, input, Nc);
     240        strncpy(output, input, Nc);
    244241
    245242        // copy the key replacement to the start of the key
    246 
    247         strcpy (&output[Nc], replace);
     243        strcpy(&output[Nc], replace);
    248244        Nc += strlen (replace);
    249245
    250246        // copy the remainder to the end of the replacement
    251         strcpy (&output[Nc], p + strlen(key));
    252 
    253         psFree (input);
     247        strcpy(&output[Nc], p + strlen(key));
     248
     249        psFree(input);
    254250        input = output;
    255251    }
     
    257253}
    258254
     255psArray *psStringSplitArray(const char *string, const char *splitters, bool multi)
     256{
     257
     258    psList *list = psStringSplit(string, splitters, multi);
     259    psArray *array = psListToArray(list);
     260    psFree (list);
     261    return array;
     262}
     263
     264#ifndef whitespace
     265#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
     266#endif
     267
     268/* Strip whitespace from the start and end of STRING. */
     269size_t psStringStrip(char *string)
     270{
     271    long i;
     272
     273    if (!string || strlen(string) == 0) {
     274        return 0;
     275    }
     276
     277    for (i = 0; i < strlen(string) && whitespace(string[i]); i++)
     278        ; // No action
     279    if (i) {
     280        memmove (string, string + i, strlen(string+i)+1);
     281    }
     282    for (i = strlen (string) - 1; (i > 0) && whitespace(string[i]); i--)
     283        ; // No action
     284    string[++i] = 0;
     285
     286    return i;
     287}
  • trunk/psLib/src/sys/psString.h

    r7300 r7380  
    1414 *  @author David Robbins, MHPCC
    1515 *
    16  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2006-06-02 21:33:34 $
     16 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2006-06-07 03:22:06 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    107107);
    108108
    109 // given the input string, search for all copies of the key, and replace with the replacement value
     109// Same as psStringSplit, but return result as an array
     110psArray *psStringSplitArray(const char *string, // String to split
     111                            const char *splitters, // Characters on which to split
     112                            bool multipleAreSignificant // Are multiple occurences significant?
     113                           );
     114
     115// Given the input string, search for all copies of the key, and replace with the replacement value
    110116// the input string may be freed if not needed
    111 char *psStringSubstitute (
    112     char *input,    ///< input string to be modified
    113     char *replace,    ///< replacement value
    114     char *key    ///< string to be replaced in input
    115 );
     117char *psStringSubstitute (char *input,  ///< input string to be modified
     118                          const char *replace, ///< replacement value
     119                          const char *key ///< string to be replaced in input
     120                         );
     121
     122// strip whitespace from head and tail of string
     123size_t psStringStrip(char *string);
     124
    116125
    117126/** @} */// Doxygen - End of SystemGroup Functions
  • trunk/psLib/src/types/Makefile.am

    r7210 r7380  
    1212        psMetadata.c \
    1313        psMetadataConfig.c \
     14        psMetadataItemParse.c \
     15        psMetadataItemCompare.c \
    1416        psPixels.c \
    1517        psArguments.c
     
    2628        psMetadata.h \
    2729        psMetadataConfig.h \
     30        psMetadataItemParse.h \
     31        psMetadataItemCompare.h \
    2832        psPixels.h \
    2933        psArguments.h
  • trunk/psLib/src/types/psMetadata.c

    r7368 r7380  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-06-06 22:54:22 $
     14 *  @version $Revision: 1.108 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-06-07 03:22:06 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    445445    return out;
    446446}
     447
     448
     449// may need to extend this to change the keyname in the copy
     450bool psMetadataItemTransfer(psMetadata *out, const psMetadata *in, const char *key)
     451{
     452
     453    psMetadataItem *item = psMetadataLookup(in, key);
     454    if (!item) {
     455        return false;
     456    }
     457
     458    return psMetadataAddItem(out, item, PS_LIST_TAIL, PS_META_REPLACE);
     459}
     460
    447461
    448462bool psMetadataAddItem(psMetadata *md,
  • trunk/psLib/src/types/psMetadata.h

    r7368 r7380  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.76 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2006-06-06 22:54:22 $
     13*  @version $Revision: 1.77 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2006-06-07 03:22:06 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    361361);
    362362
     363// Copy a metadata item from one psMetadata to another
     364bool psMetadataItemTransfer(psMetadata *out, // Destination: copy is placed here
     365                            const psMetadata *in, // Source: item comes from here
     366                            const char *key // key to identify the metadata item
     367                           );
     368
    363369/** Add existing metadata item to metadata collection.
    364370 *
Note: See TracChangeset for help on using the changeset viewer.