Changeset 4097
- Timestamp:
- Jun 3, 2005, 11:43:17 AM (21 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
src/pmObjects.c (modified) (14 diffs)
-
test/tst_pmObjects01.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmObjects.c
r4030 r4097 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 5-25 20:28:32$7 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-06-03 21:43:03 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 298 298 XXX: In the output psArray elements, should we use the image row/column offsets? 299 299 Currently, we do not. 300 301 XXX: Merge with CVS 1.20. This had the proper code for images with a single 302 row or column. 300 303 *****************************************************************************/ 301 304 psArray *pmFindImagePeaks(const psImage *image, … … 306 309 if ((image->numRows == 1) || (image->numCols == 1)) { 307 310 psError(PS_ERR_UNKNOWN, true, "Currently, input image must have at least 2 rows and 2 columns."); 311 return(NULL); 308 312 } 309 313 psVector *tmpRow = NULL; … … 321 325 for (psU32 i = 0 ; i < row1->n ; i++ ) { 322 326 col = row1->data.U32[i]; 323 324 327 // 325 328 // Determine if pixel (0,0) is a peak. … … 329 332 (image->data.F32[row][col] > image->data.F32[row+1][col]) && 330 333 (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) { 334 331 335 if (image->data.F32[row][col] > threshold) { 332 336 list = MyListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE); … … 622 626 623 627 // XXX EAM : I added this code to stay on the image. So did George 624 psS32 SubImageStartRow = PS_MAX (0, SubImageCenterRow - outerRadiusS32);625 psS32 SubImageEndRow = PS_MIN (image->numRows - 1, SubImageCenterRow + outerRadiusS32);626 psS32 SubImageStartCol = PS_MAX (0, SubImageCenterCol - outerRadiusS32);627 psS32 SubImageEndCol = PS_MIN (image->numCols - 1, SubImageCenterCol + outerRadiusS32);628 psS32 SubImageStartRow = PS_MAX(0, SubImageCenterRow - outerRadiusS32); 629 psS32 SubImageEndRow = PS_MIN(image->numRows - 1, SubImageCenterRow + outerRadiusS32); 630 psS32 SubImageStartCol = PS_MAX(0, SubImageCenterCol - outerRadiusS32); 631 psS32 SubImageEndCol = PS_MIN(image->numCols - 1, SubImageCenterCol + outerRadiusS32); 628 632 // AnulusWidth == number of pixels width in the annulus. We add one since 629 633 // the pixels at the inner AND outher radius are included. … … 670 674 // SubImageEndCol, 671 675 // SubImageEndRow); 672 psImage *subImage = NULL;673 676 // printf("pmSourceLocalSky: subimage width/length is (%d, %d)\n", subImage->numCols, subImage->numRows); 677 psRegion tmpRegion = psRegionSet(SubImageStartCol, 678 SubImageEndCol, 679 SubImageStartRow, 680 SubImageEndRow); 681 psImage *subImage = psImageSubset((psImage *) image, tmpRegion); 682 674 683 psImage *subImageMask = psImageAlloc(subImage->numCols, 675 684 subImage->numRows, … … 1310 1319 psFree(source->models); 1311 1320 } 1321 if (!((model == PS_MODEL_GAUSS) || 1322 (model == PS_MODEL_PGAUSS) || 1323 (model == PS_MODEL_WAUSS) || 1324 (model == PS_MODEL_TWIST_GAUSS) || 1325 (model == PS_MODEL_SERSIC) || 1326 (model == PS_MODEL_SERSIC_CORE))) { 1327 psError(PS_ERR_UNKNOWN, true, "Undefined psModelType"); 1328 return(false); 1329 } 1330 1312 1331 source->models = pmModelAlloc(model); 1313 1332 … … 1873 1892 psVector *x) 1874 1893 { 1894 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 1895 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 1875 1896 psF32 X = x->data.F32[0] - params->data.F32[2]; 1876 1897 psF32 Y = x->data.F32[1] - params->data.F32[3]; … … 1907 1928 psVector *x) 1908 1929 { 1930 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 1931 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 1909 1932 psF32 X = x->data.F32[0] - params->data.F32[2]; 1910 1933 psF32 Y = x->data.F32[1] - params->data.F32[3]; … … 1945 1968 psVector *x) 1946 1969 { 1970 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 1971 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 1947 1972 psF32 X = x->data.F32[0] - params->data.F32[2]; 1948 1973 psF32 Y = x->data.F32[1] - params->data.F32[2]; … … 1991 2016 psVector *x) 1992 2017 { 2018 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 2019 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 1993 2020 psF32 X = x->data.F32[0] - params->data.F32[2]; 1994 2021 psF32 Y = x->data.F32[1] - params->data.F32[3]; … … 2047 2074 psVector *x) 2048 2075 { 2076 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 2077 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 2049 2078 psError(PS_ERR_UNKNOWN, true, "This function is not implemented yet."); 2050 2079 return(0.0); … … 2070 2099 psVector *x) 2071 2100 { 2101 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 2102 PS_ASSERT_VECTOR_NON_NULL(x, NAN); 2072 2103 psError(PS_ERR_UNKNOWN, true, "This function is not implemented yet."); 2073 2104 return(0.0); -
trunk/psModules/test/tst_pmObjects01.c
r4096 r4097 19 19 * abd never deallocate, no error is generated. 20 20 * 21 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-06-03 2 0:34:47 $21 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-06-03 21:43:17 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 62 62 int main(int argc, char* argv[]) 63 63 { 64 //return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);65 test02();64 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 65 // test02(); 66 66 } 67 67 … … 484 484 bool test_pmFindImagePeaks(int numRows, int numCols) 485 485 { 486 printf("-------------- Calling test_pmFind VectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols);486 printf("-------------- Calling test_pmFindImagePeaks on an %d-by-%d image. --------------\n", numRows, numCols); 487 487 // if ((numRows < 4) || (numCols < 4)) { 488 488 // printf("WARNING: Don't call this test with a smaller than 4-by-4 image.\n"); … … 549 549 ((tmpPeak->x == numCols-1) && (tmpPeak->y == 0)) || 550 550 ((tmpPeak->x == numCols-1) && (tmpPeak->y == numRows-1))) { 551 if (!(tmpPeak->class & PM_PEAK_LONE) || 552 !(tmpPeak->class & PM_PEAK_EDGE)) { 553 printf("TEST ERROR: (0) peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 551 if (!((tmpPeak->class & PM_PEAK_LONE) || (tmpPeak->class & PM_PEAK_EDGE))) { 552 printf("TEST ERROR: (0) peak at (%d, %d) (%f) ->class set improperly (0x%x).", 553 tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 554 printf(" should be (0x%x or 0x%x).\n", PM_PEAK_LONE, PM_PEAK_EDGE); 554 555 testStatus = false; 555 556 } 556 557 } else if ((tmpPeak->x == numCols/2) && (tmpPeak->y == numRows/2)) { 557 if (!(tmpPeak->class & PM_PEAK_LONE)) { 558 printf("TEST ERROR: (1) peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 558 if (tmpPeak->class != PM_PEAK_LONE) { 559 printf("TEST ERROR: (1) peak at (%d, %d) (%f) ->class set improperly (0x%x).\n", 560 tmpPeak->y, tmpPeak->x, tmpPeak->counts, tmpPeak->class); 561 printf(" should be (0x%x).\n", PM_PEAK_LONE); 559 562 testStatus = false; 560 563 } … … 610 613 // testStatus&= test_pmFindImagePeaks(2, 5); 611 614 // testStatus&= test_pmFindImagePeaks(5, 2); 612 // HEY 613 testStatus&= test_pmFindImagePeaks(1, 1);614 testStatus&= test_pmFindImagePeaks(1, 8);615 testStatus&= test_pmFindImagePeaks(8, 1);615 // HEY: add code for small images 616 // testStatus&= test_pmFindImagePeaks(1, 1); 617 // testStatus&= test_pmFindImagePeaks(1, 8); 618 // testStatus&= test_pmFindImagePeaks(8, 1); 616 619 testStatus&= test_pmFindImagePeaks(TST02_NUM_ROWS, TST02_NUM_COLS); 617 620 testStatus&= test_pmFindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS); … … 849 852 testStatus = false; 850 853 } 851 852 printf("----------------------------------------------------------------------------------\n");853 printf("Calling pmSourceLocalSky with subImage startRow < 0. Should generate error and return NULL.\n");854 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2);855 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2);856 tmpPeak->y = 1;857 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0);858 if (rc != NULL) {859 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n");860 psFree(rc);861 testStatus = false;862 }863 printf("----------------------------------------------------------------------------------\n");864 printf("Calling pmSourceLocalSky with subImage endRow > numRows. Should generate error and return NULL.\n");865 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2);866 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2);867 tmpPeak->y = TST04_NUM_ROWS;868 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0);869 if (rc != NULL) {870 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n");871 psFree(rc);872 testStatus = false;873 }874 printf("----------------------------------------------------------------------------------\n");875 printf("Calling pmSourceLocalSky with subImage startCol < 0. Should generate error and return NULL.\n");876 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2);877 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2);878 tmpPeak->x = 1;879 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0);880 if (rc != NULL) {881 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n");882 psFree(rc);883 testStatus = false;884 }885 printf("----------------------------------------------------------------------------------\n");886 printf("Calling pmSourceLocalSky with subImage endCol > numCols. Should generate error and return NULL.\n");887 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2);888 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2);889 tmpPeak->x = TST04_NUM_COLS;890 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, (psF32) TST04_INNER_RADIUS, (psF32) TST04_OUTER_RADIUS);891 if (rc != NULL) {892 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n");893 psFree(rc);894 testStatus = false;895 }896 854 /* XXX: This is commented out since the EAM modification no longer generated NULLS for these tests. 855 printf("----------------------------------------------------------------------------------\n"); 856 printf("Calling pmSourceLocalSky with subImage startRow < 0. Should generate error and return NULL.\n"); 857 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 858 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 859 tmpPeak->y = 1; 860 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 861 if (rc != NULL) { 862 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n"); 863 psFree(rc); 864 testStatus = false; 865 } 866 printf("----------------------------------------------------------------------------------\n"); 867 printf("Calling pmSourceLocalSky with subImage endRow > numRows. Should generate error and return NULL.\n"); 868 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 869 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 870 tmpPeak->y = TST04_NUM_ROWS; 871 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 872 if (rc != NULL) { 873 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n"); 874 psFree(rc); 875 testStatus = false; 876 } 877 printf("----------------------------------------------------------------------------------\n"); 878 printf("Calling pmSourceLocalSky with subImage startCol < 0. Should generate error and return NULL.\n"); 879 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 880 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 881 tmpPeak->x = 1; 882 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 883 if (rc != NULL) { 884 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n"); 885 psFree(rc); 886 testStatus = false; 887 } 888 printf("----------------------------------------------------------------------------------\n"); 889 printf("Calling pmSourceLocalSky with subImage endCol > numCols. Should generate error and return NULL.\n"); 890 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 891 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 892 tmpPeak->x = TST04_NUM_COLS; 893 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, (psF32) TST04_INNER_RADIUS, (psF32) TST04_OUTER_RADIUS); 894 if (rc != NULL) { 895 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL psSource.\n"); 896 psFree(rc); 897 testStatus = false; 898 } 899 */ 897 900 898 901 // … … 1130 1133 } 1131 1134 1132 printf("----------------------------------------------------------------------------------\n"); 1133 printf("Calling pmSourceSetPixelCircle with subImage startCol < 0. Should generate error and return NULL.\n"); 1134 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1135 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1136 tmpSource->peak->x = 1; 1137 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1138 if (rc == true) { 1139 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1140 testStatus = false; 1141 } 1142 1143 printf("----------------------------------------------------------------------------------\n"); 1144 printf("Calling pmSourceSetPixelCircle with subImage endCol > numCols. Should generate error and return NULL.\n"); 1145 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1146 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1147 tmpSource->peak->x = TST06_NUM_COLS; 1148 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1149 if (rc == true) { 1150 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1151 testStatus = false; 1152 } 1153 1154 printf("----------------------------------------------------------------------------------\n"); 1155 printf("Calling pmSourceSetPixelCircle with subImage startRow < 0. Should generate error and return NULL.\n"); 1156 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1157 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1158 tmpSource->peak->y = 1; 1159 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1160 if (rc == true) { 1161 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1162 testStatus = false; 1163 } 1164 1165 printf("----------------------------------------------------------------------------------\n"); 1166 printf("Calling pmSourceSetPixelCircle with subImage endRow > numRows. Should generate error and return NULL.\n"); 1167 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1168 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1169 tmpSource->peak->y = TST06_NUM_ROWS; 1170 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1171 if (rc == true) { 1172 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1173 testStatus = false; 1174 } 1175 1135 /* XXX: Commented away since the EAM mods no longer produced errors. 1136 printf("----------------------------------------------------------------------------------\n"); 1137 printf("Calling pmSourceSetPixelCircle with subImage startCol < 0. Should generate error and return NULL.\n"); 1138 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1139 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1140 tmpSource->peak->x = 1; 1141 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1142 if (rc == true) { 1143 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1144 testStatus = false; 1145 } 1146 1147 printf("----------------------------------------------------------------------------------\n"); 1148 printf("Calling pmSourceSetPixelCircle with subImage endCol > numCols. Should generate error and return NULL.\n"); 1149 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1150 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1151 tmpSource->peak->x = TST06_NUM_COLS; 1152 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1153 if (rc == true) { 1154 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1155 testStatus = false; 1156 } 1157 1158 printf("----------------------------------------------------------------------------------\n"); 1159 printf("Calling pmSourceSetPixelCircle with subImage startRow < 0. Should generate error and return NULL.\n"); 1160 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1161 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1162 tmpSource->peak->y = 1; 1163 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1164 if (rc == true) { 1165 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1166 testStatus = false; 1167 } 1168 1169 printf("----------------------------------------------------------------------------------\n"); 1170 printf("Calling pmSourceSetPixelCircle with subImage endRow > numRows. Should generate error and return NULL.\n"); 1171 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1172 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1173 tmpSource->peak->y = TST06_NUM_ROWS; 1174 rc = pmSourceSetPixelCircle(tmpSource, imgData, 10.0); 1175 if (rc == true) { 1176 printf("TEST ERROR: pmSourceSetPixelCircle() returned TRUE.\n"); 1177 testStatus = false; 1178 } 1179 */ 1176 1180 printf("----------------------------------------------------------------------------------\n"); 1177 1181 printf("Calling pmSourceSetPixelCircle with valid data.\n");
Note:
See TracChangeset
for help on using the changeset viewer.
