IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 11, 2005, 12:25:39 PM (21 years ago)
Author:
gusciora
Message:

....

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmImageCombine.c

    r4425 r4992  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-06-29 01:39:10 $
     10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-09-11 22:25:39 $
    1212 *
    1313 *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
     
    308308/******************************************************************************
    309309XXX: Directly from Paul Price
    310 XXX: Must add mask parameter, use it in gradient calculation.
    311310 *****************************************************************************/
    312 static psF32 CalcGradient(psImage *image,
    313                           psS32 x,
    314                           psS32 y)
     311static psF32 CalcGradient(
     312    psImage *image,
     313    psImage *imageMask,
     314    psS32 x,
     315    psS32 y
     316)
    315317{
    316318    psTrace("ImageCombine.CalcGradient", 4, "Calling CalcGradient(%d, %d)\n", x, y);
     
    324326    int yMin = PS_MAX(y - 1, 0);
    325327    int yMax = PS_MIN(y + 1, image->numRows - 1);
    326     for (int j = yMin; j <= yMax; j++) {
    327         for (int i = xMin; i <= xMax; i++) {
    328             if ((i != x) && (j != y)) {
    329                 pixels->data.F32[num] = image->data.F32[j][i];
    330                 mask->data.U8[num] = 0;
    331                 num++;
     328    if (imageMask != NULL) {
     329        for (int j = yMin; j <= yMax; j++) {
     330            for (int i = xMin; i <= xMax; i++) {
     331                if ((i != x) && (j != y) && (0 == imageMask->data.U8[j][i])) {
     332                    pixels->data.F32[num] = image->data.F32[j][i];
     333                    mask->data.U8[num] = 0;
     334                    num++;
     335                } else {
     336                    mask->data.U8[num] = 1;
     337                }
    332338            }
    333339        }
    334     }
     340    } else {
     341        //
     342        // This code is simply the previous loop without the imageMask.
     343        // XXX: Consider restructuring this.
     344        //
     345        for (int j = yMin; j <= yMax; j++) {
     346            for (int i = xMin; i <= xMax; i++) {
     347                if ((i != x) && (j != y)) {
     348                    pixels->data.F32[num] = image->data.F32[j][i];
     349                    mask->data.U8[num] = 0;
     350                    num++;
     351                } else {
     352                    mask->data.U8[num] = 1;
     353                }
     354            }
     355        }
     356    }
     357
    335358    pixels->n = num;
    336359    mask->n = num;
     
    472495XXX: The inToOut and outToIn transforms are confusing.  Verify that what
    473496     I think they mean syncs with PWP.
    474 XXX: Must add mask parameter, use it in gradient calculation.
    475497 *****************************************************************************/
    476 psArray *pmRejectPixels(const psArray *images,          ///< Array of input images
    477                         const psArray *errors,          ///< The pixels which were rejected in the combination
    478                         const psArray *inToOut,         ///< Transformation from input to output system
    479                         const psArray *outToIn,         ///< Transformation from output to input system
    480                         psF32 rejThreshold,             ///< Rejection threshold
    481                         psF32 gradLimit                 ///< Gradient limit
    482                        )
     498psArray *pmRejectPixels(
     499    const psArray *images,              ///< Array of input images
     500    const psArray *masks,               ///< Array of input image masks
     501    const psArray *errors,              ///< The pixels which were rejected in the combination
     502    const psArray *inToOut,             ///< Transformation from input to output system
     503    const psArray *outToIn,             ///< Transformation from output to input system
     504    psF32 rejThreshold,                 ///< Rejection threshold
     505    psF32 gradLimit                     ///< Gradient limit
     506)
    483507{
    484508    psTrace("ImageCombine.pmRejectPixels", 3, "Calling pmRejectPixels()\n");
    485509    PS_ASSERT_PTR_NON_NULL(images, NULL);
     510    for (psS32 im = 0 ; im < images->n ; im++) {
     511        psImage *tmpImage = (psImage *) images->data[im];
     512        PS_ASSERT_IMAGE_NON_NULL(tmpImage, NULL);
     513        PS_ASSERT_IMAGE_NON_EMPTY(tmpImage, NULL);
     514        PS_ASSERT_IMAGE_TYPE(tmpImage, PS_TYPE_F32, NULL);
     515        if (masks != NULL) {
     516            PS_ASSERT_INT_EQUAL(images->n, masks->n, NULL);
     517            psImage *tmpMask = (psImage *) masks->data[im];
     518            PS_ASSERT_IMAGE_NON_NULL(tmpMask, NULL);
     519            PS_ASSERT_IMAGE_NON_EMPTY(tmpMask, NULL);
     520            PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL);
     521            PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL);
     522        }
     523        PS_ASSERT_IMAGES_SIZE_EQUAL(((psImage *) images->data[0]), tmpImage, NULL);
     524    }
    486525    PS_ASSERT_PTR_NON_NULL(errors, NULL);
    487526    PS_ASSERT_PTR_NON_NULL(inToOut, NULL);
     
    492531    PS_ASSERT_INT_EQUAL(numImages, inToOut->n, NULL);
    493532    PS_ASSERT_INT_EQUAL(numImages, outToIn->n, NULL);
    494     // XXX: Loop through all images, ensure their sizes are equal
    495533
    496534    //
     
    570608                    if (im != otherImg) {
    571609                        // Map the outCoords to inCoords that for otherImg space.
     610                        psImage *tmpMask = NULL;
     611                        if (masks != NULL) {
     612                            tmpMask = masks->data[otherImg];
     613                        }
    572614                        psPlaneTransformApply(inCoords,
    573615                                              (psPlaneTransform * )outToIn->data[otherImg],
     
    577619                        if ((xPix >= 0) && (xPix <= ((psImage*)(images->data[otherImg]))->numCols - 1) &&
    578620                                (yPix >= 0) && (yPix <= ((psImage*)(images->data[otherImg]))->numRows - 1)) {
    579                             meanGrads += CalcGradient(images->data[otherImg], xPix, yPix);
     621                            meanGrads += CalcGradient(images->data[otherImg], tmpMask, xPix, yPix);
    580622                            numGrads++;
    581623                        }
Note: See TracChangeset for help on using the changeset viewer.