IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 10, 2005, 2:33:44 PM (21 years ago)
Author:
gusciora
Message:

I added some missing code (for adding pixels to pixelLists).

File:
1 edited

Legend:

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

    r3877 r3878  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-05-10 23:48:19 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-05-11 00:33:44 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psPixels.h"
    2828
    29 
     29//
     30// The following macros define how big the initial pixel list will be, and
     31// how much it should be incremented when realloc'ed.
     32//
     33#define PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH 100
     34#define PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH_INC 100
    3035/******************************************************************************
    3136pmCombineImages(combine, questionablePixels, images, errors, masks, maskVal,
     
    9398    PS_PTR_CHECK_NULL(stats, combine);
    9499
    95     // Allocate an initialize the combined image, if necessary.
     100    // Allocate and initialize the combined image, if necessary.
    96101    if (combine == NULL) {
    97102        combine = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     
    100105        }
    101106    }
     107
     108    //
     109    // Allocate the questionablePixels psArray, if necesssary, then create a psPixels
     110    // struct for each image.
     111    //
     112    if (*questionablePixels == NULL) {
     113        *questionablePixels = psArrayAlloc(numImages);
     114    } else if ((*questionablePixels)->n != numImages) {
     115        *questionablePixels = psArrayRealloc(*questionablePixels, numImages);
     116    }
     117    for (psS32 im = 0 ; im < numImages ; im++) {
     118        psFree((*questionablePixels)->data[im]);
     119        ((*questionablePixels)->data[im]) = (psPtr *) psPixelsAlloc(PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH);
     120    }
     121    //
     122    // qpPtr is used to maintain a count of the questionable pixels for each image.
     123    //
     124    psVector *qpPtr = psVectorAlloc(numImages, PS_TYPE_S32);
     125    PS_VECTOR_SET_S32(qpPtr, 0);
    102126
    103127    //
     
    178202                        pixelMask->data.F32[im] = maskVal;
    179203                        //
    180                         // XXX: Must Code This.
    181                         // XXX: Add this to the list of questionable pixels.
     204                        // XXX: These data structures indirections are getting complicated.
    182205                        //
     206                        psS32 ptr = qpPtr->data.S32[im];
     207                        psPixels *pixelListPtr = ((psPixels *) ((*questionablePixels)->data[im]));
     208                        if (ptr >= pixelListPtr->n) {
     209                            (*questionablePixels)->data[im] = (psPtr *) psPixelsRealloc(((psPixels *) ((*questionablePixels)->data[im])), ((((psPixels *) ((*questionablePixels)->data[im]))->n) + PS_COMBINE_IMAGE_INITIAL_PIXEL_LIST_LENGTH_INC));
     210                        }
     211                        // XXX: Can the realloc() fail?  Must we check for NULL?
     212                        ((psPixels *) ((*questionablePixels)->data[im]))->data[ptr].x = col;
     213                        ((psPixels *) ((*questionablePixels)->data[im]))->data[ptr].y = row;
     214                        (qpPtr->data.S32[im])++;
    183215                    }
    184216                }
     
    229261    psFree(pixelMask);
    230262    psFree(pixelErrors);
    231 
     263    psFree(qpPtr);
    232264
    233265    return(combine);
     
    274306}
    275307
     308//
     309// The following macros define how big the initial pixel list will be, and
     310// how much it should be incremented when realloc'ed.
     311//
     312#define PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH 100
     313#define PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH_INC 100
    276314/******************************************************************************
    277315pmRejectPixels(images, errors, inToOut, outToIn, rejThreshold,
     
    302340    // XXX: Loop through all images, ensure their sizes are equal?
    303341
     342    //
     343    // Create the psArray of psPixelLists, one for each image, for rejected pixels.
     344    //
     345    psArray *rejects = psArrayAlloc(numImages);
     346    for (psS32 im = 0 ; im < numImages ; im++) {
     347        rejects->data[im] = (psPtr *) psPixelsAlloc(PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH);
     348    }
     349    //
     350    // rPtr is used to maintain a count of the questionable pixels for each image.
     351    //
     352    psVector *rPtr = psVectorAlloc(numImages, PS_TYPE_S32);
     353    PS_VECTOR_SET_S32(rPtr, 0);
     354
     355
    304356    psS32 numCols = ((psImage *) images->data[0])->numCols;
    305357    psS32 numRows = ((psImage *) images->data[0])->numRows;
     
    310362    psPlane *outCoords = psAlloc(sizeof(psPlane));
    311363
    312     for (psS32 img = 0 ; img < numImages ; img++) {
     364    for (psS32 im = 0 ; im < numImages ; im++) {
    313365        //
    314366        // Extract data from psArrays.
    315367        //
    316         psPixels *pixelList = (psPixels *) errors->data[img];
    317         psImage *currImage = (psImage *) images->data[img];
     368        psPixels *pixelList = (psPixels *) errors->data[im];
     369        psImage *currImage = (psImage *) images->data[im];
    318370        myRegion->x0 = 0;
    319371        myRegion->x1 = currImage->numCols - 1;
    320372        myRegion->y0 = 0;
    321373        myRegion->y1 = currImage->numRows - 1;
    322         psPlaneTransform *myInToOut = (psPlaneTransform *) inToOut->data[img];
    323         psPlaneTransform *myOutToIn = (psPlaneTransform *) outToIn->data[img];
     374        psPlaneTransform *myInToOut = (psPlaneTransform *) inToOut->data[im];
     375        psPlaneTransform *myOutToIn = (psPlaneTransform *) outToIn->data[im];
    324376
    325377        //
     
    341393        //
    342394        for (psS32 p = 0 ; p < pixelList->n ; p++) {
    343             inCoords->x = 0.5 + (psF32) (pixelList->data)->x;
    344             inCoords->y = 0.5 + (psF32) (pixelList->data)->y;
     395            inCoords->x = 0.5 + (psF32) (pixelList->data[p]).x;
     396            inCoords->y = 0.5 + (psF32) (pixelList->data[p]).y;
    345397            psPlaneTransformApply(outCoords, myInToOut, inCoords);
    346398
     
    358410                //
    359411                for (psS32 otherImg = 0 ; otherImg < numImages ; otherImg++) {
    360                     if (img != otherImg) {
     412                    if (im != otherImg) {
    361413                        // Map the outCoords to inCoords that for otherImg space.
    362414                        psPlaneTransformApply(inCoords, (psPlaneTransform * )outToIn->data[otherImg], outCoords);
     
    383435                if (meanGrads < gradLimit) {
    384436                    //
    385                     // XXX: Add this to the list of questionable pixels.
    386                     // XXX: Must Code This.
     437                    // Add this to the list of questionable pixels.  We must ensure that the
     438                    // pixelList is large enough; if not, we realloc()
    387439                    //
     440                    psS32 ptr = rPtr->data.S32[im];
     441                    psPixels *pixelListPtr = (psPixels *) rejects->data[im];
     442                    if (ptr >= pixelListPtr->n) {
     443                        rejects->data[im] = (psPtr *) psPixelsRealloc(((psPixels *) rejects->data[im]),
     444                                            ((((psPixels *) rejects->data[im])->n) + PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH_INC));
     445                    }
     446                    // XXX: Can the realloc() fail?  Must we check for NULL?
     447                    ((psPixels *) rejects->data[im])->data[ptr].x = (pixelList->data[p]).x;
     448                    ((psPixels *) rejects->data[im])->data[ptr].y = (pixelList->data[p]).y;
     449                    (rPtr->data.S32[im])++;
    388450                }
    389451            }
     
    400462    return(NULL);
    401463}
    402 // This code is
    403 
     464
Note: See TracChangeset for help on using the changeset viewer.