Changeset 1604 for trunk/psLib/src/image/psImageManip.c
- Timestamp:
- Aug 19, 2004, 4:48:38 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageManip.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r1520 r1604 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-08- 13 00:02:03$13 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-08-20 02:48:38 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psImageExtraction.h" 32 32 33 int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax) 33 int psImageClip(psImage* input, 34 psF64 min, 35 psF64 vmin, 36 psF64 max, 37 psF64 vmax) 34 38 { 35 39 int numClipped = 0; … … 125 129 } 126 130 127 int psImageClipNaN(psImage* input, psF64 value) 131 int psImageClipNaN(psImage* input, 132 psF64 value) 128 133 { 129 134 int numClipped = 0; … … 164 169 } 165 170 166 int psImageOverlaySection(psImage* image, const psImage* overlay, int col0, int row0, const char *op) 171 int psImageOverlaySection(psImage* image, 172 const psImage* overlay, 173 int col0, 174 int row0, 175 const char *op) 167 176 { 168 177 unsigned int imageNumRows; … … 267 276 } 268 277 269 int psImageClipComplexRegion(psImage* input, psC64 min, psC64 vmin, psC64 max, psC64 vmax) 278 int psImageClipComplexRegion(psImage* input, 279 psC64 min, 280 psC64 vmin, 281 psC64 max, 282 psC64 vmax) 270 283 { 271 284 int numClipped = 0; … … 340 353 } 341 354 342 psImage* psImageRebin(psImage* out, const psImage* in, unsigned int scale, const psStats* stats) 355 psImage* psImageRebin(psImage* out, 356 const psImage* in, 357 const psImage* restrict mask, 358 unsigned int maskVal, 359 unsigned int scale, 360 const psStats* stats) 343 361 { 344 362 int inRows; … … 346 364 int outRows; 347 365 int outCols; 348 psVector* vec; // vector to hold 349 350 // the values of 351 // a single bin. 366 psVector* vec; // vector to hold the values of a single bin. 367 psVector* maskVec = NULL; // vector to hold the mask of a single bin. 368 psMaskType* maskData = NULL; 352 369 psStats* myStats; 353 370 double statVal; … … 377 394 } 378 395 396 vec = psVectorAlloc(scale * scale, in->type.type); 397 398 if (mask != NULL) { 399 if (mask->type.type != PS_TYPE_MASK) { 400 psError(__func__, "The mask datatype must be %s (%d).", 401 PS_TYPE_MASK_NAME, 402 mask->type.type); 403 psFree(out); 404 psFree(vec); 405 return NULL; 406 } 407 maskVec = psVectorAlloc(scale * scale, PS_TYPE_MASK); 408 maskData = maskVec->data.PS_TYPE_MASK_DATA; 409 } 410 379 411 myStats = psAlloc(sizeof(psStats)); 380 412 *myStats = *stats; 381 382 vec = psVectorAlloc(scale * scale, in->type.type);383 413 384 414 // create output image. 385 415 inRows = in->numRows; 386 416 inCols = in->numCols; 387 outRows = (inRows + scale - 1) / scale; // round-up 388 // for 389 // remainders 390 outCols = (inCols + scale - 1) / scale; // round-up 391 // for 392 // remainders 417 outRows = (inRows + scale - 1) / scale; // round-up for remainders 418 outCols = (inCols + scale - 1) / scale; // round-up for remainders 393 419 out = psImageRecycle(out, outCols, outRows, in->type.type); 394 420 395 421 #define PS_IMAGE_REBIN_CASE(type) \ 396 422 case PS_TYPE_##type: { \ 423 ps##type* outRowData; \ 397 424 ps##type* vecData = vec->data.type; \ 425 psMaskType* inRowMask = NULL; \ 398 426 for (int row = 0; row < outRows; row++) { \ 399 ps##type*outRowData = out->data.type[row]; \427 outRowData = out->data.type[row]; \ 400 428 int inCurrentRow = row*scale; \ 401 429 int inNextRow = (row+1)*scale; \ … … 406 434 for (int inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \ 407 435 ps##type* inRowData = in->data.type[inRow]; \ 436 if (mask != NULL) { \ 437 inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \ 438 } \ 408 439 for (int inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \ 440 if (maskData != NULL) { \ 441 maskData[n] = inRowMask[inCol]; \ 442 } \ 409 443 vecData[n++] = inRowData[inCol]; \ 410 444 } \ 411 445 } \ 412 446 vec->n = n; \ 413 myStats = psVectorStats(myStats,vec, NULL,0); \447 myStats = psVectorStats(myStats,vec,maskVec,maskVal); \ 414 448 p_psGetStatValue(myStats,&statVal); \ 415 449 outRowData[col] = (ps##type)statVal; \ … … 444 478 } 445 479 446 psImage* psImageResample(psImage* out, const psImage* in, int scale, psImageInterpolateMode mode) 480 psImage* psImageResample(psImage* out, 481 const psImage* in, 482 int scale, 483 psImageInterpolateMode mode) 447 484 { 448 485 int outRows; … … 496 533 } 497 534 498 psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy) 535 psImage* psImageRoll(psImage* out, 536 const psImage* in, 537 int dx, 538 int dy) 499 539 { 500 540 int outRows; … … 808 848 psImage* psImageShift(psImage* out, 809 849 const psImage* in, 810 float dx, float dy, psF64 unexposedValue, psImageInterpolateMode mode) 850 float dx, 851 float dy, 852 psF64 unexposedValue, 853 psImageInterpolateMode mode) 811 854 { 812 855 int outRows;
Note:
See TracChangeset
for help on using the changeset viewer.
