Changeset 12187
- Timestamp:
- Mar 2, 2007, 12:19:21 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
r12186 r12187 7 7 /// @author Eugene Magnier, IfA 8 8 /// 9 /// @version $Revision: 1. 49$ $Name: not supported by cvs2svn $10 /// @date $Date: 2007-03-02 2 1:48:12$9 /// @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2007-03-02 22:19:21 $ 11 11 /// 12 12 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 274 274 } 275 275 276 psImage *psImage MaskConvolve(const psImage *mask, psMaskType maskVal, const psKernel *kernel)276 psImage *psImageConvolveMask(const psImage *mask, psMaskType maskVal, const psKernel *kernel) 277 277 { 278 278 PS_ASSERT_IMAGE_NON_NULL(mask, NULL); … … 290 290 int numCols = mask->numCols; // Number of columns 291 291 292 psImage *out = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Output mask 293 294 // Dereference mask images 292 295 psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA; 293 psImage *out = psImageAlloc(numCols, numRows, PS_TYPE_MASK); 294 psImageInit(out, 0); 295 296 for (int kRow = yMin; kRow <= yMax; kRow++) { 297 for (int kCol = xMin; kCol <= xMax; kCol++) { 298 psMaskType kValue = kernel->kernel[kRow][kCol]; // Value of the kernel 299 if (kValue == 0) { 296 psMaskType **outData = out->data.PS_TYPE_MASK_DATA; 297 298 // Propagate the non-masked values 299 for (int row = 0; row < numRows; row++) { 300 for (int col = 0; col < numCols; col++) { 301 outData[row][col] = maskData[row][col] & ~maskVal; 302 } 303 } 304 305 for (int row = 0; row < numRows; row++) { 306 for (int col = 0; col < numCols; col++) { 307 if (maskData[row][col] & maskVal) { 308 // It's already masked --- move on 300 309 continue; 301 310 } 302 for (int row = PS_MAX(kRow, 0); row < PS_MIN(numRows, numRows - kRow); row++) { 303 for (int col = PS_MAX(kCol, 0); col < PS_MIN(numCols, numCols - kCol); col++) { 304 if (maskData[row][col] & maskVal) { 305 out->data.PS_TYPE_MASK_DATA[row + kRow][col + kCol] = maskVal; 306 } 311 psMaskType pixel = 0; // New pixel value 312 for (int kRow = PS_MAX(yMin, -row); kRow <= PS_MIN(yMax, numRows - row - 1); kRow++) { 313 for (int kCol = PS_MAX(xMin, -col); kCol <= PS_MIN(xMax, numCols - col - 1); kCol++) { 314 pixel |= maskData[row + kRow][col + kCol] & maskVal; 307 315 } 308 316 } 317 outData[row][col] |= pixel; 309 318 } 310 319 } -
trunk/psLib/src/imageops/psImageConvolve.h
r12179 r12187 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-03-02 2 1:05:52$7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-03-02 22:19:21 $ 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 126 126 ); 127 127 128 /// Convolve a mask image with a kernel 129 /// 130 /// Returns a mask, grown by the supplied kernel. Only those pixels specified by the maskVal are grown; the 131 /// rest are simply propagated. 132 psImage *psImageConvolveMask(const psImage *mask, psMaskType maskVal, const psKernel *kernel); 133 134 128 135 /// Smooths an image by parts using 1D Gaussian independently in x and y. 129 136 ///
Note:
See TracChangeset
for help on using the changeset viewer.
