IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6778


Ignore:
Timestamp:
Apr 4, 2006, 3:49:41 PM (20 years ago)
Author:
drobbin
Message:

Edited functions wrt subimage v parent image issue.

Location:
trunk/psLib
Files:
6 edited

Legend:

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

    r6750 r6778  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-04-01 02:43:57 $
     12 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-04-05 01:49:40 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r6770 r6778  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-04-04 22:04:45 $
     10 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-04-05 01:49:40 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    333333        return NULL;
    334334    }
    335     /*
    336         if (col1 < 1) {
    337             col1 += input->numCols;
    338         }
    339 
    340         if (row1 < 1) {
    341             row1 += input->numRows;
    342         }
    343 
    344         if (    col0 < 0 ||
    345                 row0 < 0 ||
    346                 col1 > input->numCols ||
    347                 row1 > input->numRows ||
    348                 col0 >= col1 ||
    349                 row0 >= row1) {
    350             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    351                     PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
    352                     col0, col1, row0, row1,
    353                     input->numCols, input->numRows);
    354             psFree(out);
    355             return NULL;
    356         }
    357     */
     335
    358336    //Make sure x0 of region is inside image.  If so, set col0 to corresponding index number.
    359337    if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) {
     
    709687        return NULL;
    710688    }
    711     /*
    712         //Make sure x1 of region is valid.  If negative, index from tail (if valid).
    713         if (col1 < 0) {
    714             col1 += input->numCols;
    715             if (col1 < 0) {
    716                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    717                         "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n",
    718                         region.x1, col1+input->col0, input->col0, input->col0+input->numCols);
    719                 psFree(out);
    720                 return NULL;
    721             }
    722         } else if (col1 >= input->col0 && col1 < (input->col0 + input->numCols) ) {
    723             col1 -= input->col0;
    724         } else {
    725             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    726                     "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n",
    727                     region.x1, col1, input->col0, input->col0+input->numCols);
    728             psFree(out);
    729             return NULL;
    730         }
    731         //Make sure y1 of region is valid.  If negative, index from tail (if valid).
    732         if (row1 < 0) {
    733             row1 += input->numRows;
    734             if (row1 < 0) {
    735                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    736                         "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n",
    737                         region.y1, row1+input->row0, input->row0, input->row0+input->numRows);
    738                 psFree(out);
    739                 return NULL;
    740             }
    741         } else if (row1 >= input->row0 && row1 < (input->row0 + input->numRows) ) {
    742             row1 -= input->row0;
    743         } else {
    744             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    745                     "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n",
    746                     region.y1, row1, input->row0, input->row0+input->numRows);
    747             psFree(out);
    748             return NULL;
    749         }
    750     */
    751     /*    //Now make sure that the region makes sense.
    752         if (col0 > col1 || row0 > row1) {
    753             if (col0 > col1) {
    754                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    755                         "Invalid psRegion specified.  x0=%f=%f is greater than x1=%f=%f.\n",
    756                         region.x0, col0, region.x1, col1);
    757             } else {
    758                 psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    759                         "Invalid psRegion specified.  y0=%f=%f is greater than y1=%f=%f.\n",
    760                         region.y0, row0, region.y1, row1);
    761             }
    762             psFree(out);
    763             return NULL;
    764         } else if (col0 == col1 && row0 == row1) {
    765             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    766                     "Invalid psRegion specified.  Region contains only 1 pixel.\n");
    767             psFree(out);
    768             return NULL;
    769         }
    770     */
    771689    if (col1 < 0 || row1 < 0 || col0 < 0 || row0 < 0 || col0 >= numCols || col1 >= numCols ||
    772690            row0 >= numRows || row1 >= numRows) {
     
    778696    float endCol = col1;
    779697    float endRow = row1;
    780     /*
    781         float startCol = region.x0;
    782         float startRow = region.y0;
    783         float endCol = region.x1;
    784         float endRow = region.y1;
    785         if (startCol < 0 || startCol >= numCols ||
    786                 startRow < 0 || startRow >= numRows ||
    787                 endCol < 0 || endCol >= numCols ||
    788                 endRow < 0 || endRow >= numRows) {
    789             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    790                     PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE,
    791                     startCol,startRow,endCol,endRow,
    792                     numCols-1,numRows-1);
    793             psFree(out);
    794             return NULL;
    795         }
    796     */
    797698
    798699    if (mode < PS_INTERPOLATE_FLAT ) {
  • trunk/psLib/src/imageops/psImageStats.c

    r6750 r6778  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.91 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-04-01 02:43:57 $
     11 *  @version $Revision: 1.92 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-04-05 01:49:40 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    657657        }
    658658        region = psRegionForImage(mask, region);
    659      
     659
    660660        if (region.x0 == region.x1 || region.y0 == region.y1) {
    661661            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
     
    670670    PS_ASSERT_INT_POSITIVE(mask->numRows, -1);
    671671
    672     /*    x0 = (int)(roundf(region.x0));
    673         x1 = (int)(roundf(region.x1));
    674         y0 = (int)(roundf(region.y0));
    675         y1 = (int)(roundf(region.y1));
    676     */
    677672    int col0 = (int)(roundf(region.x0));
    678673    int col1 = (int)(roundf(region.x1));
     
    753748        return -1;
    754749    }/* else if (col0 == col1 && row0 == row1) {
    755             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    756                     "Invalid psRegion specified.  Region contains only 1 pixel.\n");
    757             return -1;
    758         }
    759     */
     750                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     751                        "Invalid psRegion specified.  Region contains only 1 pixel.\n");
     752                return -1;
     753            }
     754        */
    760755    x0 = col0;
    761756    x1 = col1;
  • trunk/psLib/src/mathtypes/psImage.c

    r6750 r6778  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.100 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-04-01 02:43:57 $
     11 *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-04-05 01:49:41 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    703703}
    704704
    705 bool p_psImagePrint (int fd, psImage *a, char *name)
     705bool p_psImagePrint (int fd,
     706                     psImage *a,
     707                     char *name)
    706708{
    707709    write(fd,"matrix: ",8);
     
    730732{
    731733
    732     /*    if (input == NULL) {
    733             psError(PS_ERR_BAD_PARAMETER_NULL,true,
    734                     PS_ERRORTEXT_psImage_IMAGE_NULL);
     734    PS_ASSERT_IMAGE_NON_NULL(input, unexposedValue);
     735    /*    if ( x < input->col0 || x >= (input->col0 + input->numCols) ) {
     736            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     737                "x-input in psImagePixelInterpolate is outside of image region.\n");
    735738            return unexposedValue;
    736739        }
     740        if ( y < input->row0 || y >= (input->row0 + input->numRows) ) {
     741            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     742                "y-input in psImagePixelInterpolate is outside of image region.\n");
     743            return unexposedValue;
     744        }
     745        x -= input->col0;
     746        y -= input->row0;
    737747    */
    738     PS_ASSERT_IMAGE_NON_NULL(input, unexposedValue);
    739     if (input->row0 != 0 || input->col0 != 0) {
    740         x += input->col0;
    741         y += input->row0;
    742     }
    743748
    744749    #define PSIMAGE_PIXEL_INTERPOLATE_CASE(TYPE)                             \
  • trunk/psLib/test/imageops/tst_psImagePixelExtract.c

    r6770 r6778  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2006-04-04 22:04:46 $
     8*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2006-04-05 01:49:41 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    100100        } \
    101101    } \
    102     out = psImageSlice(out,positions,image,mask,1,psRegionSet(c/10,c/10+M,r/10,r/10+N),DIRECTION,stat); \
     102    image->col0 = 1; \
     103    image->row0 = 1; \
     104    out = psImageSlice(out,positions,image,mask,1, \
     105                       psRegionSet(1+c/10,1+c/10+M,1+r/10,1+r/10+N),DIRECTION,stat); \
    103106    \
    104107    if (out->n != TRUTH_SIZE) { \
  • trunk/psLib/test/imageops/tst_psImageStats.c

    r6750 r6778  
    634634    }
    635635
     636    //Test a subimage.
     637    reg.y0 = 1;
     638    reg.y1 = 5;
     639    numPix2 = -1;
     640    in2->row0 = 1;
     641    numPix2 = psImageCountPixelMask(in2, reg, 1);
     642    if (numPix2 != 2) {
     643        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     644                "psImageCountPixelMask returned incorrect pixel count %ld (!=2)\n", numPix2);
     645        return 11;
     646    }
     647
    636648    psFree(in);
    637649    psFree(in2);
Note: See TracChangeset for help on using the changeset viewer.