IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6631


Ignore:
Timestamp:
Mar 17, 2006, 10:38:19 AM (20 years ago)
Author:
drobbin
Message:

Updated ImageRow, Col, Slice with respect to Sub-image v. parent-image specs.

Location:
trunk/psLib
Files:
3 edited

Legend:

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

    r6484 r6631  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-02-24 23:43:15 $
     10 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-03-17 20:38:19 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5151                     int row)
    5252{
    53     if (input == NULL) {
    54         psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    55         return NULL;
    56     }
    57     if (row >= input->numRows) {
     53    if (input == NULL || input->data.V == NULL) {
     54        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     55                PS_ERRORTEXT_psImage_IMAGE_NULL);
     56        psFree(out);
     57        return NULL;
     58    }
     59    PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL);
     60    PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL);
     61    PS_ASSERT_INT_POSITIVE(input->numCols, NULL);
     62    PS_ASSERT_INT_POSITIVE(input->numRows, NULL);
     63    if (row >= (input->numRows + input->row0) ) {
    5864        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    5965                "Specified row number is out of range for specified image.\n");
    6066        return NULL;
    61     }
    62     if (row < 0) {
     67    } else if ( row < input->row0 && row >= 0 ) {
     68        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     69                "Specified row number is out of range for specified image.\n");
     70        return NULL;
     71    } else if ( row < 0 ) {
    6372        row += input->numRows;
    64         if (row < 0) {
     73        if ( row < 0 ) {
    6574            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    6675                    "Specified row number is out of range for specified image.\n");
    6776            return NULL;
    6877        }
    69     }
     78    } else {
     79        row -= input->row0;
     80    }
     81
    7082    psVectorRecycle(out, input->numCols, input->type.type);
    7183
     
    146158                     int column)
    147159{
    148     if (input == NULL) {
    149         psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    150         return NULL;
    151     }
    152     if (column >= input->numCols) {
     160    if (input == NULL || input->data.V == NULL) {
     161        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     162                PS_ERRORTEXT_psImage_IMAGE_NULL);
     163        psFree(out);
     164        return NULL;
     165    }
     166    PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL);
     167    PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL);
     168    PS_ASSERT_INT_POSITIVE(input->numCols, NULL);
     169    PS_ASSERT_INT_POSITIVE(input->numRows, NULL);
     170    if (column >= (input->numCols + input->col0) ) {
    153171        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    154172                "Specified column number is out of range for specified image.\n");
    155173        return NULL;
    156     }
    157     if (column < 0) {
     174    } else if ( column < input->col0 && column >= 0 ) {
     175        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     176                "Specified column number is out of range for specified image.\n");
     177        return NULL;
     178    } else if ( column < 0 ) {
    158179        column += input->numCols;
    159         if (column < 0) {
     180        if ( column < 0 ) {
    160181            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    161182                    "Specified column number is out of range for specified image.\n");
    162183            return NULL;
    163184        }
    164     }
    165 
     185    } else {
     186        column -= input->col0;
     187    }
    166188
    167189    psVectorRecycle(out, input->numRows, input->type.type);
     
    213235
    214236}
    215 
    216237
    217238psVector* psImageSlice(psVector* out,
     
    242263        return NULL;
    243264    }
    244 
    245     if (col1 < 1) {
     265    PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL);
     266    PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL);
     267    PS_ASSERT_INT_POSITIVE(input->numCols, NULL);
     268    PS_ASSERT_INT_POSITIVE(input->numRows, NULL);
     269    /*
     270        if (col1 < 1) {
     271            col1 += input->numCols;
     272        }
     273     
     274        if (row1 < 1) {
     275            row1 += input->numRows;
     276        }
     277     
     278        if (    col0 < 0 ||
     279                row0 < 0 ||
     280                col1 > input->numCols ||
     281                row1 > input->numRows ||
     282                col0 >= col1 ||
     283                row0 >= row1) {
     284            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     285                    PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
     286                    col0, col1, row0, row1,
     287                    input->numCols, input->numRows);
     288            psFree(out);
     289            return NULL;
     290        }
     291    */
     292    //Make sure x0 of region is inside image.  If so, set col0 to corresponding index number.
     293    if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) {
     294        col0 -= input->col0;
     295    } else {
     296        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     297                "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n",
     298                region.x0, input->col0, input->col0+input->numCols);
     299        return NULL;
     300    }
     301    //Make sure y0 of region is inside image.  If so, set row0 to corresponding index number.
     302    if (row0 >= input->row0 && row0 < (input->row0 + input->numRows) ) {
     303        row0 -= input->row0;
     304    } else {
     305        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     306                "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n",
     307                region.y0, input->row0, input->row0+input->numRows);
     308        return NULL;
     309    }
     310
     311    //Make sure x1 of region is valid.  If negative, index from tail (if valid).
     312    if (col1 < 0) {
    246313        col1 += input->numCols;
    247     }
    248 
    249     if (row1 < 1) {
     314        if (col1 < 0) {
     315            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     316                    "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
     317                    region.x1, col1+input->col0, input->col0, input->col0+input->numCols);
     318            return NULL;
     319        }
     320    } else if (col1 >= input->col0 && col1 < (input->col0 + input->numCols) ) {
     321        col1 -= input->col0;
     322    } else {
     323        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     324                "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
     325                region.x1, col1, input->col0, input->col0+input->numCols);
     326        return NULL;
     327    }
     328    //Make sure y1 of region is valid.  If negative, index from tail (if valid).
     329    if (row1 < 0) {
    250330        row1 += input->numRows;
    251     }
    252 
    253     if (    col0 < 0 ||
    254             row0 < 0 ||
    255             col1 > input->numCols ||
    256             row1 > input->numRows ||
    257             col0 >= col1 ||
    258             row0 >= row1) {
    259         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    260                 PS_ERRORTEXT_psImage_SUBSET_RANGE_INVALID,
    261                 col0, col1, row0, row1,
    262                 input->numCols, input->numRows);
    263         psFree(out);
     331        if (row1 < 0) {
     332            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     333                    "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
     334                    region.y1, row1+input->row0, input->row0, input->row0+input->numRows);
     335            return NULL;
     336        }
     337    } else if (row1 >= input->row0 && row1 < (input->row0 + input->numRows) ) {
     338        row1 -= input->row0;
     339    } else {
     340        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     341                "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
     342                region.y1, row1, input->row0, input->row0+input->numRows);
     343        return NULL;
     344    }
     345    //Now make sure that the region makes sense.
     346    if (col0 > col1 || row0 > row1) {
     347        if (col0 > col1) {
     348            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     349                    "Invalid psRegion specified.  x0=%f=%d is greater than x1=%f=%d.\n",
     350                    region.x0, col0, region.x1, col1);
     351        } else {
     352            psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     353                    "Invalid psRegion specified.  y0=%f=%d is greater than y1=%f=%d.\n",
     354                    region.y0, row0, region.y1, row1);
     355        }
     356        return NULL;
     357    } else if (col0 == col1 && row0 == row1) {
     358        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     359                "Invalid psRegion specified.  Region contains only 1 pixel.\n");
    264360        return NULL;
    265361    }
     
    487583        return NULL;
    488584    }
     585    //    PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL);
     586    //    PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL);
     587    //    PS_ASSERT_INT_POSITIVE(input->numCols, NULL);
     588    //    PS_ASSERT_INT_POSITIVE(input->numRows, NULL);
    489589    psS32 numCols = input->numCols;
    490590    psS32 numRows = input->numRows;
     
    497597        return NULL;
    498598    }
     599
    499600
    500601    float startCol = region.x0;
  • trunk/psLib/src/mathtypes/psImage.c

    r6579 r6631  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-03-14 03:35:14 $
     11 *  @version $Revision: 1.99 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-03-17 20:38:19 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    293293                double complex value)
    294294{
    295     /*    if (image == NULL) {
    296             psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    297             return false;
    298         }
    299         if (x >= image->numRows || y >= image->numCols) {
    300             psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    301                 "Invalid position %d.  Position out of range (%d-%d)\n", x, );
    302             return false;
    303         }
    304 
    305         if(x < 0)
    306             x += image->numRows;
    307         if(x < 0) {
    308             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
    309             return false;
    310         }
    311 
    312         if(y < 0)
    313             y += image->numCols;
    314         if(y < 0) {
    315             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
    316             return false;
    317         }
    318 
    319     */
    320295    PS_ASSERT_IMAGE_NON_NULL(image, false);
    321296    PS_ASSERT_INT_NONNEGATIVE(image->col0, false);
     
    416391                          int y)
    417392{
    418     /*    if (image == NULL) {
    419             psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
    420             return NAN;
    421         }
    422         if (x >= image->numRows || y >= image->numCols) {
    423             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position.  Position too large\n");
    424             return NAN;
    425         }
    426 
    427         if(x < 0)
    428             x += image->numRows;
    429         if(x < 0) {
    430             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid x.  Negative number too large\n");
    431             return NAN;
    432         }
    433 
    434         if(y < 0)
    435             y += image->numCols;
    436         if(y < 0) {
    437             psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid y.  Negative number too large\n");
    438             return NAN;
    439         }
    440     */
    441393    PS_ASSERT_IMAGE_NON_NULL(image, NAN);
    442394    PS_ASSERT_INT_NONNEGATIVE(image->col0, NAN);
  • trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr

    r6484 r6631  
    2020    Following should be an error.
    2121<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    22     Specified subset range, [30:30,20:20], is invalid or outside input psImage's boundaries, [0:300,0:200].
    23 <DATE><TIME>|<HOST>|I|testImageSlice
    24     Following should be an error.
    25 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    26     Specified subset range, [301:302,20:30], is invalid or outside input psImage's boundaries, [0:300,0:200].
    27 <DATE><TIME>|<HOST>|I|testImageSlice
    28     Following should be an error.
    29 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    30     Specified subset range, [30:31,201:205], is invalid or outside input psImage's boundaries, [0:300,0:200].
    31 <DATE><TIME>|<HOST>|I|testImageSlice
    32     Following should be an error.
    33 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    34     Specified subset range, [30:301,20:21], is invalid or outside input psImage's boundaries, [0:300,0:200].
    35 <DATE><TIME>|<HOST>|I|testImageSlice
    36     Following should be an error.
    37 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    38     Specified subset range, [30:31,20:201], is invalid or outside input psImage's boundaries, [0:300,0:200].
     22    Invalid psRegion specified.  Region contains only 1 pixel.
     23<DATE><TIME>|<HOST>|I|testImageSlice
     24    Following should be an error.
     25<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     26    Specified psRegion parameter, x0=301.000000, is out of range [0,300].
     27<DATE><TIME>|<HOST>|I|testImageSlice
     28    Following should be an error.
     29<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     30    Specified psRegion parameter, y0=201.000000, is out of range [0,200].
     31<DATE><TIME>|<HOST>|I|testImageSlice
     32    Following should be an error.
     33<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     34    Specified psRegion parameter, x1=301.000000=301, is out of range [0,300].
     35<DATE><TIME>|<HOST>|I|testImageSlice
     36    Following should be an error.
     37<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     38    Specified psRegion parameter, y1=201.000000=201, is out of range [0,200].
    3939<DATE><TIME>|<HOST>|I|testImageSlice
    4040    Following should be an error.
Note: See TracChangeset for help on using the changeset viewer.