IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6806


Ignore:
Timestamp:
Apr 6, 2006, 12:55:18 PM (20 years ago)
Author:
drobbin
Message:

Made changes concerning subimage issue and testing of changes.

Location:
trunk/psLib
Files:
4 edited

Legend:

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

    r6778 r6806  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-04-05 01:49:40 $
     12 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-04-06 22:55:18 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    753753            row0 = input->row0;
    754754            col0 = input->col0;
    755             row1 = input->row0 + input->numRows;
    756             col1 = input->col0 + input->numCols;
     755            row1 = input->row0 + input->numRows - 1;
     756            col1 = input->col0 + input->numCols - 1;
    757757        }
    758758        if (col1 < 1) {
     
    782782        row0 = output->row0;
    783783        col0 = output->col0;
    784         row1 = row0+numRows;
    785         col1 = col0+numCols;
     784        row1 = row0+numRows -1;
     785        col1 = col0+numCols -1;
    786786    }
    787787
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r6805 r6806  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-04-06 04:12:27 $
     10 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-04-06 22:55:18 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    334334    }
    335335
     336    //If [0,0,0,0] specified, the whole image is to be included
     337    if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) {
     338        row0 = input->row0;
     339        col0 = input->col0;
     340        row1 = input->row0 + input->numRows - 1;
     341        col1 = input->col0 + input->numCols - 1;
     342    }
     343
    336344    //Make sure x0 of region is inside image.  If so, set col0 to corresponding index number.
    337345    if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) {
     
    341349                "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n",
    342350                region.x0, input->col0, input->col0+input->numCols-1);
     351        psFree(out);
    343352        return NULL;
    344353    }
     
    350359                "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n",
    351360                region.y0, input->row0, input->row0+input->numRows-1);
    352         return NULL;
    353     }
    354 
    355     //If [0,0,0,0] specified, the whole image is to be included
    356     if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) {
    357         row0 = input->row0;
    358         col0 = input->col0;
    359         row1 = input->row0 + input->numRows;
    360         col1 = input->col0 + input->numCols;
     361        psFree(out);
     362        return NULL;
    361363    }
    362364
     
    368370                    "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
    369371                    region.x1, col1+input->col0, input->col0, input->col0+input->numCols-1);
     372            psFree(out);
    370373            return NULL;
    371374        }
     
    376379                "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n",
    377380                region.x1, col1, input->col0, input->col0+input->numCols-1);
     381        psFree(out);
    378382        return NULL;
    379383    }
     
    385389                    "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
    386390                    region.y1, row1+input->row0, input->row0, input->row0+input->numRows-1);
     391            psFree(out);
    387392            return NULL;
    388393        }
     
    393398                "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n",
    394399                region.y1, row1, input->row0, input->row0+input->numRows-1);
     400        psFree(out);
    395401        return NULL;
    396402    }
     
    406412                    region.y0, row0, region.y1, row1);
    407413        }
     414        psFree(out);
    408415        return NULL;
    409416    } else if (col0 == col1 && row0 == row1) {
    410417        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    411418                "Invalid psRegion specified.  Region contains only 1 pixel.\n");
     419        psFree(out);
    412420        return NULL;
    413421    }
     
    679687        row0 = input->row0;
    680688        col0 = input->col0;
    681         row1 = input->row0 + input->numRows;
    682         col1 = input->col0 + input->numCols;
     689        row1 = input->row0 + input->numRows - 1;
     690        col1 = input->col0 + input->numCols - 1;
    683691    }
    684692
  • trunk/psLib/test/imageops/tst_psImagePixelExtract.c

    r6778 r6806  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2006-04-05 01:49:41 $
     8*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2006-04-06 22:55:18 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    341341    }
    342342
     343    //Added tests after subimage changes.
     344    psFree(image);
     345    image = psImageAlloc( c, r, PS_TYPE_F64 );
     346    for ( psS32 row = 0;row < r;row++ ) {
     347        psF64 *imageRow = image->data.F64[ row ];
     348        psF64 rowOffset = row * 2;
     349        for ( psS32 col = 0;col < c;col++ ) {
     350            imageRow[ col ] = col + rowOffset;
     351        }
     352    }
     353    image->col0 = 1;
     354    image->row0 = 1;
     355    psFree(out);
     356    out = NULL;
     357    out = psImageSlice(out,positions,image,mask,1,
     358                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
     359    if (out == NULL) {
     360        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     361                "psImageSlice failed to return the correct psVector.  Got NULL instead.\n");
     362        return 112;
     363    }
     364    psFree(out);
     365    out = NULL;
     366    //Return NULL for incorrect image inputs.
     367    image->row0 = -1;
     368    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     369    out = psImageSlice(out,positions,image,mask,1,
     370                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
     371    if (out != NULL) {
     372        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     373                "psImageSlice failed to return NULL for invalid specified input.\n");
     374        return 113;
     375    }
     376    image->col0 = -1;
     377    image->row0 = 1;
     378    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     379    out = psImageSlice(out,positions,image,mask,1,
     380                       psRegionSet(1,c,1,r),PS_CUT_X_POS,stat);
     381    if (out != NULL) {
     382        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     383                "psImageSlice failed to return NULL for invalid specified input.\n");
     384        return 114;
     385    }
     386    image->col0 = 1;
     387    //Return NULL for incorrect region inputs.
     388    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     389    out = psImageSlice(out,positions,image,mask,1,
     390                       psRegionSet(0,c,1,r),PS_CUT_X_POS,stat);
     391    if (out != NULL) {
     392        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     393                "psImageSlice failed to return NULL for invalid specified input.\n");
     394        return 115;
     395    }
     396    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     397    out = psImageSlice(out,positions,image,mask,1,
     398                       psRegionSet(1,c,1,r+1),PS_CUT_X_POS,stat);
     399    if (out != NULL) {
     400        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     401                "psImageSlice failed to return NULL for invalid specified input.\n");
     402        return 116;
     403    }
     404    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     405    out = psImageSlice(out,positions,image,mask,1,
     406                       psRegionSet(1,c,1,-r-2),PS_CUT_X_POS,stat);
     407    if (out != NULL) {
     408        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     409                "psImageSlice failed to return NULL for invalid specified input.\n");
     410        return 117;
     411    }
     412    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     413    out = psImageSlice(out,positions,image,mask,1,
     414                       psRegionSet(c,1,1,r),PS_CUT_X_POS,stat);
     415    if (out != NULL) {
     416        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     417                "psImageSlice failed to return NULL for invalid specified input.\n");
     418        return 118;
     419    }
     420    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     421    out = psImageSlice(out,positions,image,mask,1,
     422                       psRegionSet(1,1,1,1),PS_CUT_X_POS,stat);
     423    if (out != NULL) {
     424        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     425                "psImageSlice failed to return NULL for invalid specified input.\n");
     426        return 119;
     427    }
     428
     429    //Make sure that regions match appropriately...
     430    out = psImageSlice(out,positions,image,mask,1,
     431                       psRegionSet(1,-1,1,-1),PS_CUT_Y_NEG,stat);
     432    psVector *out2 = NULL;
     433    out2 = psImageSlice(out2,positions,image,mask,1,
     434                        psRegionSet(0,0,0,0),PS_CUT_Y_NEG,stat);
     435    if (out == NULL) {
     436        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     437                "psImageSlice incorrectly returned NULL for valid inputs.\n");
     438        return 120;
     439    } else if (out2 == NULL) {
     440        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     441                "psImageSlice incorrectly returned NULL for valid inputs.\n");
     442        return 121;
     443    } else if (out->n != out2->n) {
     444        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     445                "psImageSlice failed to return matching vectors for equivalent inputs.\n");
     446        return 122;
     447    } else if (out->data.F64[out->n-1] != out2->data.F64[out2->n-1] ) {
     448        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     449                "psImageSlice failed to return matching vectors for equivalent inputs.\n");
     450        return 123;
     451    }
     452    psFree(out2);
     453
    343454    psFree( image );
    344455    psFree( positions );
  • trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr

    r6770 r6806  
    4949<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
    5050    Input psImage mask type, psS8, is not the supported mask datatype of psU8.
     51<DATE><TIME>|<HOST>|I|testImageSlice
     52    Following should generate error message
     53<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     54    psImage input is invalid.  row0 cannot be negative.
     55<DATE><TIME>|<HOST>|I|testImageSlice
     56    Following should generate error message
     57<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     58    psImage input is invalid.  col0 cannot be negative.
     59<DATE><TIME>|<HOST>|I|testImageSlice
     60    Following should generate error message
     61<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     62    Specified psRegion parameter, x0=0.000000, is out of range [1,300].
     63<DATE><TIME>|<HOST>|I|testImageSlice
     64    Following should generate error message
     65<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     66    Specified psRegion parameter, y1=201.000000=201, is out of range [1,200].
     67<DATE><TIME>|<HOST>|I|testImageSlice
     68    Following should generate error message
     69<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     70    Specified psRegion parameter, y1=-202.000000=-1, is out of range [1,200].
     71<DATE><TIME>|<HOST>|I|testImageSlice
     72    Following should generate error message
     73<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     74    Invalid psRegion specified.  x0=300.000000=299 is greater than x1=1.000000=0.
     75<DATE><TIME>|<HOST>|I|testImageSlice
     76    Following should generate error message
     77<DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO)
     78    Invalid psRegion specified.  Region contains only 1 pixel.
    5179
    5280---> TESTPOINT PASSED (psImage{psImageSlice} | tst_psImagePixelExtract.c)
Note: See TracChangeset for help on using the changeset viewer.