Changeset 15320
- Timestamp:
- Oct 16, 2007, 1:31:03 PM (19 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 2 edited
-
psImageConvolve.c (modified) (3 diffs)
-
psImageConvolve.h (modified) (2 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 -
trunk/psLib/src/imageops/psImageConvolve.h
r14866 r15320 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $8 * @date $Date: 2007- 09-17 20:49:51$7 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-10-16 23:31:03 $ 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 153 153 ); 154 154 155 /// Convolve a mask image with a kernel 155 /// Convolve a mask image with a kernel, using direct convolution 156 156 /// 157 157 /// Returns a mask, grown by the supplied kernel. Only those pixels specified by the maskVal are grown; the 158 158 /// rest are simply propagated. 159 psImage *psImageConvolveMask(const psImage *mask, ///< Mask to convolve 160 psMaskType maskVal, ///< Mask value to convolve 161 const psKernel *kernel ///< Kernel by which to convolve 159 psImage *psImageConvolveMaskDirect(const psImage *mask, ///< Mask to convolve 160 psMaskType maskVal, ///< Mask value to convolve 161 const psKernel *kernel ///< Kernel by which to convolve 162 ); 163 164 /// Convolve a mask image with a kernel, using the FFT 165 /// 166 /// Returns a mask, grown by the supplied kernel. Only those pixels specified by the maskVal are grown; the 167 /// rest are simply propagated. Uses psImageConvolveFFT to convolve the mask, and then thresholds at the 168 /// specified level. 169 psImage *psImageConvolveMaskFFT(const psImage *mask, ///< Mask to convolve 170 psMaskType maskVal, ///< Mask value to convolve 171 const psKernel *kernel, ///< Kernel by which to convolve 172 float thresh ///< Threshold (0..1) for convolved floating-point image 162 173 ); 163 174
Note:
See TracChangeset
for help on using the changeset viewer.
