IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12187


Ignore:
Timestamp:
Mar 2, 2007, 12:19:21 PM (19 years ago)
Author:
Paul Price
Message:

Adding psImageConvolveMask

Location:
trunk/psLib/src/imageops
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageConvolve.c

    r12186 r12187  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2007-03-02 21:48:12 $
     9/// @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2007-03-02 22:19:21 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    274274}
    275275
    276 psImage *psImageMaskConvolve(const psImage *mask, psMaskType maskVal, const psKernel *kernel)
     276psImage *psImageConvolveMask(const psImage *mask, psMaskType maskVal, const psKernel *kernel)
    277277{
    278278    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
     
    290290    int numCols = mask->numCols;        // Number of columns
    291291
     292    psImage *out = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Output mask
     293
     294    // Dereference mask images
    292295    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
    300309                continue;
    301310            }
    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;
    307315                }
    308316            }
     317            outData[row][col] |= pixel;
    309318        }
    310319    }
  • trunk/psLib/src/imageops/psImageConvolve.h

    r12179 r12187  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-03-02 21:05:52 $
     7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-03-02 22:19:21 $
    99 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    126126);
    127127
     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.
     132psImage *psImageConvolveMask(const psImage *mask, psMaskType maskVal, const psKernel *kernel);
     133
     134
    128135/// Smooths an image by parts using 1D Gaussian independently in x and y.
    129136///
Note: See TracChangeset for help on using the changeset viewer.