Changeset 15320 for trunk/psLib/src/imageops/psImageConvolve.c
- Timestamp:
- Oct 16, 2007, 1:31:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageConvolve.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageConvolve.c
r14866 r15320 7 7 /// @author Eugene Magnier, IfA 8 8 /// 9 /// @version $Revision: 1.5 7$ $Name: not supported by cvs2svn $10 /// @date $Date: 2007- 09-17 20:49:51$9 /// @version $Revision: 1.58 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2007-10-16 23:31:03 $ 11 11 /// 12 12 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 313 313 } 314 314 315 psImage *psImageConvolveMask (const psImage *mask, psMaskType maskVal, const psKernel *kernel)315 psImage *psImageConvolveMaskDirect(const psImage *mask, psMaskType maskVal, const psKernel *kernel) 316 316 { 317 317 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); … … 491 491 492 492 return out; 493 } 494 495 496 psImage *psImageConvolveMaskFFT(const psImage *mask, psMaskType maskVal, const psKernel *kernel, float thresh) 497 { 498 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); 499 PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL); 500 PS_ASSERT_PTR_NON_NULL(kernel, NULL); 501 PS_ASSERT_PTR_NON_NULL(kernel->kernel, NULL); 502 PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL); 503 PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL); 504 505 int numRows = mask->numRows, numCols = mask->numCols; // Size of image 506 507 psImage *onoff = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", // Casting away const so I can use 508 psScalarAlloc(maskVal, PS_TYPE_MASK)); // Pixels on or off 509 psImage *copy = psImageCopy(NULL, onoff, PS_TYPE_F32); // Floating-point copy 510 psImage *convolved = psImageConvolveFFT(copy, NULL, 0, kernel, 0.0); 511 psFree(copy); 512 513 thresh *= maskVal; 514 for (int y = 0; y < numRows; y++) { 515 for (int x = 0; x < numCols; x++) { 516 onoff->data.PS_TYPE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ? 517 (mask->data.PS_TYPE_MASK_DATA[y][x] | maskVal) : mask->data.PS_TYPE_MASK_DATA[y][x]; 518 } 519 } 520 521 psFree(convolved); 522 523 return onoff; 493 524 } 494 525
Note:
See TracChangeset
for help on using the changeset viewer.
