IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3576


Ignore:
Timestamp:
Mar 30, 2005, 2:22:49 PM (21 years ago)
Author:
gusciora
Message:

...

Location:
trunk/psModules
Files:
1 added
2 edited

Legend:

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

    r3514 r3576  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-03-26 03:44:31 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-03-31 00:22:49 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1717#include "psConstants.h"
    1818#include "pmObjects.h"
    19 /******************************************************************************
    20  *****************************************************************************/
    21 
     19
     20/******************************************************************************
     21pmPeakAlloc(): Allocate the psPeak data structure and set appropriate members.
     22 *****************************************************************************/
    2223psPeak *pmPeakAlloc(psS32 x,
    2324                    psS32 y,
     
    3435}
    3536
     37/******************************************************************************
     38pmMomentsAlloc(): Allocate the psMoments structure and initialize the members
     39to zero.
     40 *****************************************************************************/
    3641psMoments *pmMomentsAlloc()
    3742{
     
    5661}
    5762
     63/******************************************************************************
     64pmModelAlloc(): Allocate the psModel structure, along with its parameters,
     65and initialize the type member.  Initialize the params to 0.0.
     66 *****************************************************************************/
    5867psModel *pmModelAlloc(psModelType type)
    5968{
     
    6170
    6271    tmp->type = type;
    63     tmp->Nparams = 0;
    64     tmp->params = NULL;
    65     tmp->dparams = NULL;
    6672    tmp->chisq = 0.0;
     73    switch (type) {
     74    case PS_MODEL_GAUSS:
     75        tmp->Nparams = 7;
     76        tmp->params = (psF32 *) psAlloc(7 * sizeof(PS_TYPE_F32));
     77        tmp->dparams = (psF32 *) psAlloc(7 * sizeof(PS_TYPE_F32));
     78        break;
     79    case PS_MODEL_PGAUSS:
     80        tmp->Nparams = 7;
     81        tmp->params = (psF32 *) psAlloc(7 * sizeof(PS_TYPE_F32));
     82        tmp->dparams = (psF32 *) psAlloc(7 * sizeof(PS_TYPE_F32));
     83        break;
     84    case PS_MODEL_TWIST_GAUSS:
     85        tmp->Nparams = 11;
     86        tmp->params = (psF32 *) psAlloc(11 * sizeof(PS_TYPE_F32));
     87        tmp->dparams = (psF32 *) psAlloc(11 * sizeof(PS_TYPE_F32));
     88        break;
     89    case PS_MODEL_WAUSS:
     90        tmp->Nparams = 9;
     91        tmp->params = (psF32 *) psAlloc(9 * sizeof(PS_TYPE_F32));
     92        tmp->dparams = (psF32 *) psAlloc(9 * sizeof(PS_TYPE_F32));
     93        break;
     94    case PS_MODEL_SERSIC:
     95        tmp->Nparams = 8;
     96        tmp->params = (psF32 *) psAlloc(8 * sizeof(PS_TYPE_F32));
     97        tmp->dparams = (psF32 *) psAlloc(8 * sizeof(PS_TYPE_F32));
     98        break;
     99    case PS_MODEL_SERSIC_CORE:
     100        tmp->Nparams = 12;
     101        tmp->params = (psF32 *) psAlloc(12 * sizeof(PS_TYPE_F32));
     102        tmp->dparams = (psF32 *) psAlloc(12 * sizeof(PS_TYPE_F32));
     103        break;
     104    default:
     105        psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
     106        return(NULL);
     107    }
     108
     109    for (psS32 i = 0 ; i < tmp->Nparams ; i++) {
     110        tmp->params[i] = 0.0;
     111        tmp->dparams[i] = 0.0;
     112    }
    67113
    68114    p_psMemSetDeallocator(tmp, (psFreeFcn) p_psModelFree);
     
    70116}
    71117
    72 // XXX: We don't free pixels and mask since that caused a memory error.
    73 // We might need to increase the reference counter and decrease it here.
    74 //
     118/******************************************************************************
     119XXX: We don't free pixels and mask since that caused a memory error.
     120We might need to increase the reference counter and decrease it here.
     121 *****************************************************************************/
    75122static void p_psSourceFree(psSource *tmp)
    76123{
     
    82129}
    83130
     131/******************************************************************************
     132pmSourceAlloc(): Allocate the psSource structure and initialize its members
     133to NULL.
     134 *****************************************************************************/
    84135psSource *pmSourceAlloc()
    85136{
     
    195246
    196247/******************************************************************************
     248p_psGetRowVectorFromImage(): a private function which simply returns a
     249psVector containing the specified row of data from the psImage.
     250 
    197251XXX: Is there a better way to do this?
    198252 *****************************************************************************/
     
    210264}
    211265
     266/******************************************************************************
     267MyListAddPeak(): A private function which allocates a psList, if the list
     268argument is NULL, otherwise it adds the peak to that list.
     269 *****************************************************************************/
    212270// XXX: Switch row, col args?
    213271psList *MyListAddPeak(psList *list,
     
    504562    // We define variables for code readability.
    505563    //
     564    // XXX: Since the peak->xy coords are in image, not subImage coords,
     565    // these variables should be renamed for clarity (imageCenterRow, etc).
     566    //
    506567    psS32 SubImageCenterRow = peak->y;
    507568    psS32 SubImageCenterCol = peak->x;
     
    612673 
    613674XXX: macro this for performance.
    614  
    615 XXX: should arguments be (y, x) order?
    616  *****************************************************************************/
     675  *****************************************************************************/
    617676bool CheckRadius(psPeak *peak,
    618677                 psF32 radius,
     
    627686}
    628687
     688/******************************************************************************
     689bool CheckRadius2(): private function which simply determines if the (x, y)
     690point is within the radius of the specified peak.
     691 
     692XXX: macro this for performance.
     693  *****************************************************************************/
    629694bool CheckRadius2(psF32 xCenter,
    630695                  psF32 yCenter,
     
    641706
    642707/******************************************************************************
    643 pmSourceMoments(source, radius)
     708pmSourceMoments(source, radius): this function takes a subImage defined in the
     709psSource data structure, along with the peak location, and determines the
     710various moments associated with that peak.
    644711 
    645712Requires the following to have been created:
     
    647714    psSource->peak
    648715    psSource->pixels
     716 
     717XXX: The peak calculations are done in image coords, not subImage coords.
    649718 
    650719XXX: mask values?
     
    733802
    734803/******************************************************************************
    735 pmSourceRoughClass(source, saturate, SNlim, valid): make a guess at the source
     804pmSourceRoughClass(source, metadata): make a guess at the source
    736805classification.
    737806 
    738 psSource *pmSourceRoughClass(psSource *source,
    739                              psF32 saturate,
    740                              float SNlim,
    741                              const psRegion *valid)
     807XXX: This is not useable code, as of the release date.  There remains a fair
     808bit of coding to be completed.
     809 
    742810XXX: The sigX and sigY stuff in the SDRS is unclear.
    743811 
     
    838906    // We define variables for code readability.
    839907    //
     908    // XXX: Since the peak->xy coords are in image, not subImage coords,
     909    // these variables should be renamed for clarity (imageCenterRow, etc).
     910    //
    840911    psS32 radiusS32 = (psS32) radius;
    841912    psS32 SubImageCenterRow = source->peak->y;
     
    910981/******************************************************************************
    911982pmSourceModelGuess(source, image, model): This function allocates a new
    912 psModel structure and store it in the psSource data structure specified in the
    913 argument list.  The model type is specified in the argument list.  The params
    914 array in that psModel structure are allocated, and then set to the appropriate
    915 values.  This function returns true if everything was successful.
     983psModel structure and stores it in the psSource data structure specified in
     984the argument list.  The model type is specified in the argument list.  The
     985params array in that psModel structure are allocated, and then set to the
     986appropriate values.  This function returns true if everything was successful.
    916987 
    917988XXX: Many of the initial parameters are set to 0.0 since I don't know what
    918989the appropiate initial guesses are.
     990 
     991XXX: The image argument is redundant.
     992 
     993XXX: Many parameters are based on the src->moments structure, which is in
     994image, not subImage coords.  Therefore, the calls to the model evaluation
     995functions will be in image, not subImage coords.  Remember this.
    919996 *****************************************************************************/
    920997bool pmSourceModelGuess(psSource *source,
     
    9311008        psFree(source->models);
    9321009    }
    933     source->models = pmModelAlloc(PS_MODEL_UNDEFINED);
     1010    source->models = pmModelAlloc(model);
    9341011
    9351012    switch (model) {
    9361013    case PS_MODEL_GAUSS:
    937         source->models->type = PS_MODEL_GAUSS;
    938         source->models->Nparams = 7;
    939         source->models->params = (psF32 *) psAlloc(7 * sizeof(psF32));
    940         source->models->dparams = (psF32 *) psAlloc(7 * sizeof(psF32));
    941         for (psS32 i = 0 ; i < 7 ; i++) {
    942             source->models->params[i] = 0.0;
    943             source->models->dparams[i] = 0.0;
    944         }
    9451014        source->models->params[0] = source->moments->Sky;
    9461015        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    9501019        source->models->params[5] = sqrt(2.0) / source->moments->Sy;
    9511020        source->models->params[6] = source->moments->Sxy;
    952         source->models->chisq = 0.0;
    9531021        return(true);
     1022
    9541023    case PS_MODEL_PGAUSS:
    955         source->models->type = PS_MODEL_PGAUSS;
    956         source->models->Nparams = 7;
    957         source->models->params = (psF32 *) psAlloc(7 * sizeof(psF32));
    958         source->models->dparams = (psF32 *) psAlloc(7 * sizeof(psF32));
    959         for (psS32 i = 0 ; i < 7 ; i++) {
    960             source->models->params[i] = 0.0;
    961             source->models->dparams[i] = 0.0;
    962         }
    9631024        source->models->params[0] = source->moments->Sky;
    9641025        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    9681029        source->models->params[5] = sqrt(2.0) / source->moments->Sy;
    9691030        source->models->params[6] = source->moments->Sxy;
    970         source->models->chisq = 0.0;
    9711031        return(true);
     1032
    9721033    case PS_MODEL_TWIST_GAUSS:
    973         source->models->type = PS_MODEL_TWIST_GAUSS;
    974         source->models->Nparams = 11;
    975         source->models->params = (psF32 *) psAlloc(11 * sizeof(psF32));
    976         source->models->dparams = (psF32 *) psAlloc(11 * sizeof(psF32));
    977         for (psS32 i = 0 ; i < 11 ; i++) {
    978             source->models->params[i] = 0.0;
    979             source->models->dparams[i] = 0.0;
    980         }
    981 
    9821034        source->models->params[0] = source->moments->Sky;
    9831035        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    9921044        // source->models->params[9] = SxyOuter;
    9931045        // source->models->params[10] = N;
    994 
    995         source->models->chisq = 0.0;
    9961046        return(true);
     1047
    9971048    case PS_MODEL_WAUSS:
    998 
    9991049        source->models->params[0] = source->moments->Sky;
    10001050        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    10071057        // source->models->params[7] = B2;
    10081058        // source->models->params[8] = B3;
    1009 
    1010         source->models->type = PS_MODEL_WAUSS;
    1011         source->models->Nparams = 9;
    1012         source->models->params = (psF32 *) psAlloc(9 * sizeof(psF32));
    1013         source->models->dparams = (psF32 *) psAlloc(9 * sizeof(psF32));
    1014         for (psS32 i = 0 ; i < 9 ; i++) {
    1015             source->models->params[i] = 0.0;
    1016             source->models->dparams[i] = 0.0;
    1017         }
    1018         source->models->chisq = 0.0;
    10191059        return(true);
     1060
    10201061    case PS_MODEL_SERSIC:
    1021         source->models->type = PS_MODEL_SERSIC;
    1022         source->models->Nparams = 8;
    1023         source->models->params = (psF32 *) psAlloc(8 * sizeof(psF32));
    1024         source->models->dparams = (psF32 *) psAlloc(8 * sizeof(psF32));
    1025         for (psS32 i = 0 ; i < 8 ; i++) {
    1026             source->models->params[i] = 0.0;
    1027             source->models->dparams[i] = 0.0;
    1028         }
    1029 
    10301062        source->models->params[0] = source->moments->Sky;
    10311063        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    10371069        // XXX: What are these?
    10381070        //source->models->params[7] = Nexp;
    1039 
    1040         source->models->chisq = 0.0;
    10411071        return(true);
     1072
    10421073    case PS_MODEL_SERSIC_CORE:
    1043         source->models->type = PS_MODEL_SERSIC_CORE;
    1044         source->models->Nparams = 12;
    1045         source->models->params = (psF32 *) psAlloc(12 * sizeof(psF32));
    1046         source->models->dparams = (psF32 *) psAlloc(12 * sizeof(psF32));
    1047         for (psS32 i = 0 ; i < 12 ; i++) {
    1048             source->models->params[i] = 0.0;
    1049             source->models->dparams[i] = 0.0;
    1050         }
    1051 
    10521074        source->models->params[0] = source->moments->Sky;
    10531075        source->models->params[1] = source->peak->counts - source->moments->Sky;
     
    10631085        //source->models->params[10] = SxyOuter;
    10641086        //source->models->params[11] = Nexp;
    1065 
    1066         source->models->chisq = 0.0;
    10671087        return(true);
     1088
    10681089    default:
    10691090        psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
     
    10741095/******************************************************************************
    10751096evalModel(source, level, row): a private function which evaluates the
    1076 source->model function at the specified coords.
    1077  
    1078 NOTE: The coords are in source->pixel coords, not image coords.
     1097source->model function at the specified coords.  The coords are subImage, not
     1098image coords.
     1099 
     1100NOTE: The coords are in subImage source->pixel coords, not image coords.
    10791101 
    10801102XXX: reverse order of row,col args?
    10811103 
    1082 XXX: This should probably be a public function.
     1104XXX: rename all coords in this file such that their name defines whether
     1105the coords is in subImage or image space.
     1106 
     1107XXX: This should probably be a public psModules function.
    10831108 
    10841109XXX: Use static vectors for x.
    10851110 
    10861111XXX: Figure out if it's (row, col) or (col, row) for the model functions.
     1112 
     1113XXX: For a while, the first psVectorAlloc() was generating a seg fault during
     1114testing.  Try to reproduce that and debug.
    10871115 *****************************************************************************/
    10881116psF32 evalModel(psSource *src,
     
    10901118                psU32 col)
    10911119{
     1120    PS_PTR_CHECK_NULL(src, false);
     1121    PS_PTR_CHECK_NULL(src->models, false);
     1122    PS_PTR_CHECK_NULL(src->models->params, false);
     1123
    10921124    // XXX: The following step will not be necessary if the models->params
    1093     // member is a psVector.
    1094     psVector *params = psVectorAlloc(src->models->Nparams, PS_TYPE_F32);
     1125    // member is a psVector.  Suggest to IfA.
     1126    psVector *params = psVectorAlloc(7, PS_TYPE_F32);
    10951127    for (psS32 i = 0 ; i < src->models->Nparams ; i++) {
    10961128        params->data.F32[i] = src->models->params[i];
    10971129    }
     1130
     1131    //
     1132    // Allocate the x coordinate structure and convert row/col to image space.
     1133    //
    10981134    psVector *x = psVectorAlloc(2, PS_TYPE_F32);
    10991135    x->data.F32[0] = (psF32) (col + src->pixels->col0);
    11001136    x->data.F32[1] = (psF32) (row + src->pixels->row0);
    11011137    psF32 tmpF;
    1102 
    11031138
    11041139    switch (src->models->type) {
     
    11391174XXX: reverse order of row,col args?
    11401175 
    1141 XXX: The result is returned in subImage coords, not image coords.
     1176XXX: Input row/col are in image coords.
     1177 
     1178XXX: The result is returned in image coords.
    11421179 *****************************************************************************/
    11431180psF32 findValue(psSource *source,
     
    11471184                psU32 dir)
    11481185{
     1186    //
     1187    // Convert coords to subImage space.
     1188    //
     1189    psU32 subRow = row - source->pixels->row0;
     1190    psU32 subCol = col - source->pixels->col0;
     1191
    11491192    // Ensure that the starting column is allowable.
    1150     if (!((0 <= col) && (col < source->pixels->numCols))) {
     1193    if (!((0 <= subCol) && (subCol < source->pixels->numCols))) {
    11511194        psError(PS_ERR_UNKNOWN, true, "Starting column outside subImage range");
    11521195        return(NAN);
    11531196    }
    1154 
    1155     psF32 oldValue = evalModel(source, row, col);
     1197    if (!((0 <= subRow) && (subRow < source->pixels->numRows))) {
     1198        psError(PS_ERR_UNKNOWN, true, "Starting row outside subImage range");
     1199        return(NAN);
     1200    }
     1201
     1202    psF32 oldValue = evalModel(source, subRow, subCol);
    11561203    if (oldValue == level) {
    1157         return(((psF32) col));
     1204        return(((psF32) (subCol + source->pixels->col0)));
    11581205    }
    11591206
     
    11711218        lastColumn = source->pixels->numCols;
    11721219    }
    1173     col+=incr;
    1174 
    1175     while (col != lastColumn) {
    1176         psF32 newValue = evalModel(source, row, col);
     1220    subCol+=incr;
     1221
     1222    while (subCol != lastColumn) {
     1223        psF32 newValue = evalModel(source, subRow, subCol);
    11771224        if (oldValue == level) {
    1178             return(col);
     1225            return((psF32) (subCol + source->pixels->col0));
    11791226        }
    11801227
    11811228        if ((newValue <= level) && (level <= oldValue)) {
    11821229            // This is simple linear interpolation.
    1183             return( ((psF32) col) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) );
     1230            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - newValue) / (oldValue - newValue)) );
    11841231        }
    11851232
    11861233        if ((oldValue <= level) && (level <= newValue)) {
    11871234            // This is simple linear interpolation.
    1188             return( ((psF32) col) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) );
    1189         }
    1190 
    1191         col+=incr;
     1235            return( ((psF32) (subCol + source->pixels->col0)) + ((psF32) incr) * ((level - oldValue) / (newValue - oldValue)) );
     1236        }
     1237
     1238        subCol+=incr;
    11921239    }
    11931240
    11941241    return(NAN);
    11951242}
    1196 /******************************************************************************
     1243
     1244/******************************************************************************
     1245pmSourceContour(src, img, level, mode): For an input subImage, and model, this
     1246routine returns a psArray of coordinates that evaluate to the specified level.
     1247 
    11971248XXX: Probably should remove the "image" argument.
    1198 XXX: What type should the output coordinate vectors consist of?
     1249XXX: What type should the output coordinate vectors consist of?  col,row?
    11991250XXX: Why a pmArray output?
    12001251XXX: doex x,y correspond with col,row or row/col?
     1252XXX: What is momde?
     1253XXX: The top, bottom of the contour is not correctly determined.
    12011254 *****************************************************************************/
    12021255psArray *pmSourceContour(psSource *source,
     
    12061259{
    12071260    PS_PTR_CHECK_NULL(source, false);
     1261    PS_PTR_CHECK_NULL(image, false);
    12081262    PS_PTR_CHECK_NULL(source->moments, false);
    12091263    PS_PTR_CHECK_NULL(source->peak, false);
     
    12281282        // Starting at peak pixel, search leftwards for the column intercept.
    12291283        psF32 leftIntercept = findValue(source, level, row, col, 0);
     1284        if (isnan(leftIntercept)) {
     1285            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     1286            psFree(xVec);
     1287            psFree(yVec);
     1288            return(NULL);
     1289        }
    12301290        xVec->data.F32[row] = ((psF32) source->pixels->col0) + leftIntercept;
    12311291
    12321292        // Starting at peak pixel, search rightwards for the column intercept.
     1293
    12331294        psF32 rightIntercept = findValue(source, level, row, col, 1);
     1295        if (isnan(rightIntercept)) {
     1296            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     1297            psFree(xVec);
     1298            psFree(yVec);
     1299            return(NULL);
     1300        }
     1301        //printf("HERE the intercepts are (%.2f, %.2f)\n", leftIntercept, rightIntercept);
    12341302        xVec->data.F32[row+xVec->n] = ((psF32) source->pixels->col0) + rightIntercept;
    12351303
     
    12481316        // Starting at peak pixel, search leftwards for the column intercept.
    12491317        psF32 leftIntercept = findValue(source, level, row, col, 0);
     1318        if (isnan(leftIntercept)) {
     1319            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     1320            psFree(xVec);
     1321            psFree(yVec);
     1322            return(NULL);
     1323        }
    12501324        xVec->data.F32[row] = ((psF32) source->pixels->col0) + leftIntercept;
    12511325
    12521326        // Starting at peak pixel, search rightwards for the column intercept.
    12531327        psF32 rightIntercept = findValue(source, level, row, col, 1);
     1328        if (isnan(rightIntercept)) {
     1329            psError(PS_ERR_UNKNOWN, true, "Could not find contour edge (NAN)");
     1330            psFree(xVec);
     1331            psFree(yVec);
     1332            return(NULL);
     1333        }
    12541334        xVec->data.F32[row+xVec->n] = ((psF32) source->pixels->col0) + rightIntercept;
    12551335
     
    12941374    PS_IMAGE_CHECK_NULL(image, false);
    12951375    PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, false);
    1296 
    12971376    psBool rc;
    12981377    psS32 count = 0;
     
    13061385    psArray *x = psArrayAlloc(count);
    13071386    psVector *y = psVectorAlloc(count, PS_TYPE_F32);
     1387    psS32 tmpCnt = 0;
    13081388    for (psS32 i = 0 ; i < source->pixels->numRows ; i++) {
    13091389        for (psS32 j = 0 ; j < source->pixels->numCols ; j++) {
    13101390            if (source->mask->data.U8[i][j] == 0) {
    13111391                psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    1312                 // XXX: Should we use the subimage offsets here, or does it not matter?
    1313                 coord->data.F32[0] = (psF32) (i);
    1314                 coord->data.F32[1] = (psF32) (j);
    1315                 x->data[count] = (psPtr *) coord;
    1316                 y->data.F32[count] = source->pixels->data.F32[i][j];
     1392                // XXX: Convert i/j to image space:
     1393                coord->data.F32[0] = (psF32) (i + source->pixels->row0);
     1394                coord->data.F32[1] = (psF32) (j + source->pixels->col0);
     1395                x->data[tmpCnt] = (psPtr *) coord;
     1396                y->data.F32[tmpCnt] = source->pixels->data.F32[i][j];
     1397                tmpCnt++;
    13171398            }
    13181399        }
     
    13261407    switch (source->models->type) {
    13271408    case PS_MODEL_GAUSS:
     1409
    13281410        rc = psMinimizeLMChi2(myMin, NULL, params, NULL, x, y,
    13291411                              NULL, (psMinimizeLMChi2Func) p_pmMinLM_Gauss2D_Vec);
     
    13741456    PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, false);
    13751457
    1376     // XXX: make static, document.
    1377     // We use a length of 100 here since it is larger enough for all models.
    1378     #define MAX_PARAMS 100
    1379 
    1380     psVector *params = psVectorAlloc(MAX_PARAMS, PS_TYPE_F32);
     1458    psVector *params = psVectorAlloc(src->models->Nparams, PS_TYPE_F32);
    13811459    psVector *x = psVectorAlloc(2, PS_TYPE_F32);
    1382     if (src->models->Nparams > MAX_PARAMS) {
    1383         psError(PS_ERR_UNKNOWN, true, "Internal error: increase MAX_PARAMS to %d", src->models->Nparams);
    1384     }
    13851460    for (psS32 i = 0 ; i < src->models->Nparams ; i++) {
    13861461        params->data.F32[i] = src->models->params[i];
     
    13901465        for (psS32 j = 0 ; j < src->pixels->numCols ; j++) {
    13911466            psF32 pixelValue;
    1392             // XXX: Should you use offsets here?
    1393             // XXX: Make sure you have col/row order correct.
    13941467            // XXX: Should you be adding the pixels for the entire subImage,
    13951468            // or a radius of pixels around it?
    13961469
    1397             x->data.F32[0] = (float) j;
    1398             x->data.F32[1] = (float) i;
     1470            // Convert i/j to imace coord space:
     1471            // XXX: Make sure you have col/row order correct.
     1472            psS32 imageRow = i + src->pixels->row0;
     1473            psS32 imageCol = j + src->pixels->col0;
     1474
     1475            x->data.F32[0] = (float) imageCol;
     1476            x->data.F32[1] = (float) imageRow;
    13991477            switch (src->models->type) {
    14001478            case PS_MODEL_GAUSS:
     
    14281506            // XXX: Must figure out how to calculate the image coordinates and
    14291507            // how to use the boolean "center" flag.
    1430             psS32 imageRow = i + src->pixels->row0;
    1431             psS32 imageCol = j + src->pixels->col0;
    14321508
    14331509            image->data.F32[imageRow][imageCol]+= pixelValue;
     
    14891565XXX: I added the following.  Must conform with IfA.  If deriv==NULL, then
    14901566we simply don't perform the derivative calculations.
     1567 
     1568XXX: It is not clear whether the subImage coords, or the image coords should
     1569be used when calling these functions.  I don't think it really matters, as
     1570long as we are consistent.
    14911571 *****************************************************************************/
    14921572psF32 pmMinLM_Gauss2D(psVector *deriv,
     
    15531633        }
    15541634
     1635        psVector *tmpVec2 = (psVector *) x->data[i];
    15551636        tmpVec->data.F32[i] = pmMinLM_Gauss2D(tmpRow,
    15561637                                              params,
    1557                                               (psVector *) x->data[i]);
     1638                                              tmpVec2);
    15581639
    15591640        for (psS32 j = 0 ; j < tmpRow->n ; j++) {
  • trunk/psModules/test/Makefile.am

    r3231 r3576  
    1 bin_PROGRAMS = tst_pmFlatField tst_pmMaskBadPixels tst_pmNonLinear tst_pmSubtractBias tst_pmReadoutCombine tst_pmSubtractSky
     1bin_PROGRAMS = tst_pmFlatField tst_pmMaskBadPixels tst_pmNonLinear tst_pmSubtractBias tst_pmReadoutCombine tst_pmSubtractSky tst_pmObjects01
    22
    33AM_LDFLAGS = -L../src -lpsmodule $(LDFLAGS)
     
    1414
    1515tst_pmSubtractSky_SOURCES = tst_pmSubtractSky.c
     16
     17tst_pmObjects_SOURCES = tst_pmObjects01.c
     18
Note: See TracChangeset for help on using the changeset viewer.