Changeset 6631 for trunk/psLib/src/imageops/psImagePixelExtract.c
- Timestamp:
- Mar 17, 2006, 10:38:19 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImagePixelExtract.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImagePixelExtract.c
r6484 r6631 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 2-24 23:43:15$10 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-03-17 20:38:19 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 51 51 int row) 52 52 { 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) ) { 58 64 psError(PS_ERR_BAD_PARAMETER_NULL, true, 59 65 "Specified row number is out of range for specified image.\n"); 60 66 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 ) { 63 72 row += input->numRows; 64 if ( row < 0) {73 if ( row < 0 ) { 65 74 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 66 75 "Specified row number is out of range for specified image.\n"); 67 76 return NULL; 68 77 } 69 } 78 } else { 79 row -= input->row0; 80 } 81 70 82 psVectorRecycle(out, input->numCols, input->type.type); 71 83 … … 146 158 int column) 147 159 { 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) ) { 153 171 psError(PS_ERR_BAD_PARAMETER_NULL, true, 154 172 "Specified column number is out of range for specified image.\n"); 155 173 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 ) { 158 179 column += input->numCols; 159 if ( column < 0) {180 if ( column < 0 ) { 160 181 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 161 182 "Specified column number is out of range for specified image.\n"); 162 183 return NULL; 163 184 } 164 } 165 185 } else { 186 column -= input->col0; 187 } 166 188 167 189 psVectorRecycle(out, input->numRows, input->type.type); … … 213 235 214 236 } 215 216 237 217 238 psVector* psImageSlice(psVector* out, … … 242 263 return NULL; 243 264 } 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) { 246 313 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) { 250 330 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"); 264 360 return NULL; 265 361 } … … 487 583 return NULL; 488 584 } 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); 489 589 psS32 numCols = input->numCols; 490 590 psS32 numRows = input->numRows; … … 497 597 return NULL; 498 598 } 599 499 600 500 601 float startCol = region.x0;
Note:
See TracChangeset
for help on using the changeset viewer.
