Index: /trunk/psLib/test/image/Makefile
===================================================================
--- /trunk/psLib/test/image/Makefile	(revision 1357)
+++ /trunk/psLib/test/image/Makefile	(revision 1358)
@@ -3,6 +3,6 @@
 ##  Makefile:   test/collections
 ##
-##  $Revision: 1.1 $  $Name: not supported by cvs2svn $
-##  $Date: 2004-07-28 02:42:20 $
+##  $Revision: 1.2 $  $Name: not supported by cvs2svn $
+##  $Date: 2004-07-31 02:27:16 $
 ##
 ##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,4 +26,5 @@
 tst_psImageStats02 \
 tst_psImageStats03 \
+tst_psImageExtraction
 
 OBJS = $(addsuffix .o,$(TARGET))
Index: /trunk/psLib/test/image/tst_psImageExtraction.c
===================================================================
--- /trunk/psLib/test/image/tst_psImageExtraction.c	(revision 1358)
+++ /trunk/psLib/test/image/tst_psImageExtraction.c	(revision 1358)
@@ -0,0 +1,221 @@
+/** @file  tst_psImageExtraction.c
+*
+*  @brief Contains the tests for psImageExtraction.[ch]
+*
+*
+*  @author Robert DeSonia, MHPCC
+*
+*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-07-31 02:27:16 $
+*
+*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+*/
+#include<stdlib.h>
+
+#include "psTest.h"
+#include "pslib.h"
+#include "psType.h"
+
+static int testImageSlice( void );
+
+testDescription tests[] = {
+                              {
+                                  testImageSlice, 571, "psImageSlice", 0, false
+                              },
+                              {
+                                  NULL
+                              }
+                          };
+                          
+int main( int argc, char* argv[] )
+{
+    return runTestSuite( stderr, "psImage", tests, argc, argv );
+}
+
+int testImageSlice( void )
+{
+    const int r = 1000;
+    const int c = 2000;
+    const int m = r / 2;
+    const int n = r / 4;
+    psVector* out = NULL;
+    psImage* image = psImageAlloc( c, r, PS_TYPE_F32 );
+    psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
+    psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
+    
+    /*
+        This function shall extract pixels from a specified region of a psImage
+        structure into a vector using a specified statistical method.
+    
+        Verify the returned psVector structure contains expected data, if the 
+        input psImage input has known data and the psStats structure specifies 
+        a known statistical method. At least two different statistical methods 
+        should be used within a valid range of psImage data. Allow for a delta 
+        when comparing results to allow for testing a different platforms. Two 
+        cases should be used for each possible direction. Data region cases 
+        should include 0x0, 1x1, Nx1, 1xN, NxN, MxN
+     
+     */
+    
+    for ( int row = 0;row < r;row++ ) {
+            psF32* imageRow = image->data.F32[ row ];
+            psMaskType* maskRow = image->data.V[ row ];
+            psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
+            for ( int col = 0;col < c;col++ ) {
+                    imageRow[ col ] = ( psF32 ) col + rowOffset;
+                    maskRow[ col ] = 0;
+                }
+        }
+        
+    // test MxN case
+    
+    #define PSIMAGESLICE_TEST1(M,N,DIRECTION,TRUTH_SIZE,TRUTHPIX_X,TRUTHPIX_Y,TESTNUM) \
+    out = psImageSlice(out,image,mask,1,c/10,r/10,M,N,DIRECTION,stat); \
+    \
+    if (out->n != TRUTH_SIZE) { \
+            psError(__func__,"Number of results is wrong (%d, not %d)", \
+                    out->n,n); \
+            return TESTNUM*2+1; \
+        } \
+    \
+    for (int i=0;i<out->n;i++) { \
+            if (abs(out->data.F64[i]-image->data.F32[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF32)r) { \
+                    psError(__func__,"Improper result at position %d.",i); \
+                    return TESTNUM*2+2; \
+                } \
+        }
+        
+    // test MxN case
+    PSIMAGESLICE_TEST1( m, n, PS_CUT_X_POS, m, i, n / 2, 0 );
+    PSIMAGESLICE_TEST1( m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 );
+    PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_POS, n, m / 2, i, 2 );
+    PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 );
+    
+    // test Mx1 case
+    PSIMAGESLICE_TEST1( m, 1, PS_CUT_X_POS, m, i, 0, 4 );
+    PSIMAGESLICE_TEST1( m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 );
+    PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 );
+    PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 );
+    
+    // test 1xN case
+    PSIMAGESLICE_TEST1( 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 );
+    PSIMAGESLICE_TEST1( 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 );
+    PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_POS, n, 0, n - 1 - i, 10 );
+    PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 );
+    
+    // test 1x1 case
+    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 );
+    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 );
+    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 );
+    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 );
+    
+    /*
+       Verify the returned psVector structure pointer is null and program 
+       execution doesn't stop, if input psImage input is null.
+    
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, NULL, NULL, 0, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
+            return 41;
+        }
+        
+        
+    /*
+       Verify the returned psVector structure pointer is null and program 
+       execution doesn't stop, if input psStats stats is null.
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, NULL );
+    if ( out != NULL ) {
+            psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
+            return 42;
+        }
+        
+    /*
+    
+       Verify the returned psVector structure pointer is null and program 
+       executions doesn't stop, if the input direction is not set to one of 
+       the two valid values.
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, 5, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
+            return 43;
+        }
+        
+    /*
+       Verify the returned psVector structure pointer is null and program 
+       execution doesn't stop, if the input nrow and/or ncol are zero.
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 0, 0, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
+            return 44;
+        }
+        
+    /*
+       Verify the returned psVector structure pointer is null and program 
+       execution doesn't stop, if the inputs row, col, nrow, ncol specify a 
+       regions of data that is not within the input psImage structure.
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c + 1, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
+            return 45;
+        }
+        
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r + 1, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
+            return 46;
+        }
+        
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, c, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
+            return 47;
+        }
+        
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, r, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+            return 48;
+        }
+        
+    /*
+       Verify the returned psVector structure pointer is null and program 
+       execution doesn't stop, if the input psStat structure member options is 
+       zero which indicates no statistic method specified.
+    */
+    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
+    stat->options = 0;
+    out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
+    if ( out != NULL ) {
+            psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
+            return 49;
+        }
+        
+    psFree( image );
+    psFree( mask );
+    psFree( out );
+    psFree( stat );
+    
+    return 0;
+    
+}
+
+
+
+
+
+
+
+
Index: /trunk/psLib/test/image/verified/tst_psImageManip.stderr
===================================================================
--- /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1357)
+++ /trunk/psLib/test/image/verified/tst_psImageManip.stderr	(revision 1358)
@@ -30,4 +30,40 @@
 
 ---> TESTPOINT PASSED (psImage{psImageClipNAN} | tst_psImageManip.c)
+
+/***************************** TESTPOINT ******************************************\
+*             TestFile: tst_psImageManip.c                                         *
+*            TestPoint: psImage{psImageClipComplexRegion}                          *
+*             TestType: Positive                                                   *
+\**********************************************************************************/
+
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|psImageClipNaN shall modified pixel values of NaN with a specified value
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Testing clipping at 409.6+256i to 682.667+512i for psC32
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Testing clipping at 409.6+256i to 682.667+512i for psC64
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Can not perform clip on NULL image
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|psImageClipComplexRegion can not be invoked with max < min in the real image space.
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|psImageClipComplexRegion can not be invoked with max < min in the imaginary image space.
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|psImageClipComplexRegion can not be invoked with max < min in the real image space.
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmin (-6.80565e+38+0i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmin (6.80565e+38+0i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmin (-0-6.80565e+38i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmin (0+6.80565e+38i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmax (-6.80565e+38+0i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmax (6.80565e+38+0i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmax (-0-6.80565e+38i) is outside of image's psC32 pixel range
+ <DATE> <TIME> |<HOST>|I|testImageClipCo|Following should be an error:
+ <DATE> <TIME> |<HOST>|E|psImageClipComp|Specified vmax (0+6.80565e+38i) is outside of image's psC32 pixel range
+
+---> TESTPOINT PASSED (psImage{psImageClipComplexRegion} | tst_psImageManip.c)
 
 /***************************** TESTPOINT ******************************************\
