IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5214 for trunk/psLib/src/types


Ignore:
Timestamp:
Sep 30, 2005, 2:14:17 PM (21 years ago)
Author:
drobbin
Message:

Changed psPixelCoord to use float's instead of int's

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

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psPixels.c

    r5137 r5214  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-26 22:35:53 $
     9 *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-10-01 00:14:17 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232
    3333// for use by qsort, etc.
    34 static int comparePixelCoord(psPixelCoord* coord1, psPixelCoord* coord2)
     34static int comparePixelCoord(psPixelCoord* coord1,
     35                             psPixelCoord* coord2)
    3536{
    3637    // check row first
     
    7980
    8081
    81 psPixels* psPixelsRealloc(psPixels* pixels, long nalloc)
     82psPixels* psPixelsRealloc(psPixels* pixels,
     83                          long nalloc)
    8284{
    8385    if (pixels == NULL) {
     
    101103}
    102104
    103 psPixels* p_psPixelsAppend(psPixels* pixels, long growth, int x, int y)
     105psPixels* p_psPixelsAppend(psPixels* pixels,
     106                           long growth,
     107                           float x,
     108                           float y)
    104109{
    105110    if (growth < 1) {
     
    111116    }
    112117
    113     int n = pixels->n;
     118    long n = pixels->n;
    114119
    115120    pixels->data[n].x = x;
     
    121126}
    122127
    123 psPixels* psPixelsCopy(psPixels* out, const psPixels* pixels)
     128psPixels* psPixelsCopy(psPixels* out,
     129                       const psPixels* pixels)
    124130{
    125131    if (pixels == NULL) {
     
    137143}
    138144
    139 psImage *psPixelsToMask(psImage *out, const psPixels *pixels, psRegion region, psMaskType maskVal)
     145psImage *psPixelsToMask(psImage *out,
     146                        const psPixels *pixels,
     147                        psRegion region,
     148                        psMaskType maskVal)
    140149{
    141150    // check that the input pixel vector is valid
     
    154163    }
    155164
    156     int x0 = region.x0;
    157     int x1 = region.x1;
    158     int y0 = region.y0;
    159     int y1 = region.y1;
     165    float x0 = region.x0;
     166    float x1 = region.x1;
     167    float y0 = region.y0;
     168    float y1 = region.y1;
    160169
    161170    // determine the output image size
     
    165174        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    166175                PS_ERRORTEXT_psPixels_REGION_INVALID,
    167                 y0,y1,x0,x1);
     176                (int)y0,(int)y1,(int)x0,(int)x1);
    168177        psFree(out);
    169178        return NULL;
     
    178187        return NULL;
    179188    }
    180     *(psS32*)&out->row0 = y0;
    181     *(psS32*)&out->col0 = x0;
     189    *(psS32*)&out->row0 = (int)y0;
     190    *(psS32*)&out->col0 = (int)x0;
    182191
    183192    // initialize image to all zeros
     
    188197
    189198    // determine the length of the pixel vector
    190     int length = pixels->n;
     199    long length = pixels->n;
    191200
    192201    // cycle through the vector of pixels and insert pixels into image
    193202    psMaskType** outData = out->data.PS_TYPE_MASK_DATA;
    194203    for (int p = 0; p < length; p++) {
    195         psS32 x = data[p].x;
    196         psS32 y = data[p].y;
     204        float x = data[p].x;
     205        float y = data[p].y;
    197206        // pixel in region?
    198207        if (x >= x0 && x < x1 && y >= y0 && y < y1) {
    199             outData[y-y0][x-x0] |= maskVal;
     208            outData[(int)(y-y0)][(int)(x-x0)] |= maskVal;
    200209        }
    201210    }
     
    204213}
    205214
    206 psPixels* psPixelsFromMask(psPixels* out, const psImage* mask, psMaskType maskVal)
     215psPixels* psPixelsFromMask(psPixels* out,
     216                           const psImage* mask,
     217                           psMaskType maskVal)
    207218{
    208219    if (mask == NULL) {
     
    227238    // total pixels, so it is best to just start with a guess and resize if
    228239    // necessary
    229     int minPixels = numRows*numCols/100; // initial guess, 1% of pixels masked
     240    long minPixels = numRows*numCols/100; // initial guess, 1% of pixels masked
    230241    if (minPixels < 32) { // enforce a minimum size
    231242        minPixels = 32;
     
    241252
    242253    // find the mask pixels in the image
    243     int numPixels = 0;
     254    long numPixels = 0;
    244255    psPixelCoord* data = out->data;
    245256    int nalloc = out->nalloc;
     
    266277}
    267278
    268 psPixels* psPixelsConcatenate(psPixels *out,const psPixels *pixels)
     279psPixels* psPixelsConcatenate(psPixels *out,
     280                              const psPixels *pixels)
    269281{
    270282    if (pixels == NULL) {
     
    274286    }
    275287
    276     int pixelsN = pixels->n;
     288    long pixelsN = pixels->n;
    277289    psPixelCoord* pixelsData = pixels->data;
    278290
     
    284296
    285297    // make sure the out is large enough to fit the result
    286     int outN = out->n;
     298    long outN = out->n;
    287299    out = psPixelsRealloc(out,outN + pixelsN);
    288300    psPixelCoord* outData = out->data;
     
    294306    // add non-duplicate values in pixels to out
    295307    psPixelCoord pCoord;
    296     int end = outN;
    297     for (int n = 0; n < pixelsN; n++) {
     308    long end = outN;
     309    for (long n = 0; n < pixelsN; n++) {
    298310        pCoord = pixelsData[n];
    299311        if (bsearch(&pCoord, outData, outN, sizeof(psPixelCoord),
     
    318330    }
    319331
    320     int n = pixels->n;
     332    long n = pixels->n;
    321333    psPixelCoord* data = pixels->data;
    322334
     
    326338    }
    327339
    328     for (int i = 0; i < n; i++) {
    329         fprintf (fd, "(%d,%d)\n", data[i].x, data[i].y);
     340    for (long i = 0; i < n; i++) {
     341        fprintf (fd, "(%f,%f)\n", data[i].x, data[i].y);
    330342    }
    331343    fprintf (fd, "\n");
  • trunk/psLib/src/types/psPixels.h

    r5137 r5214  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-09-26 22:35:53 $
     9 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-10-01 00:14:17 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424typedef struct
    2525{
    26     int x;                             ///< x coordinate
    27     int y;                             ///< y coordinate
     26    float x;                             ///< x coordinate
     27    float y;                             ///< y coordinate
    2828}
    2929psPixelCoord;
     
    8686    long growth,
    8787    ///< number of elements to grow the psPixels list, if necessary.  if growth < 1, 10 is used.
    88     int x,                             ///< x coordinate to append
    89     int y                              ///< y coordinate to append
     88    float x,                             ///< x coordinate to append
     89    float y                              ///< y coordinate to append
    9090);
    9191
Note: See TracChangeset for help on using the changeset viewer.