Changeset 1931
- Timestamp:
- Sep 30, 2004, 8:47:23 AM (22 years ago)
- Location:
- trunk/psLib/test/image
- Files:
-
- 2 edited
-
tst_psImageManip.c (modified) (8 diffs)
-
verified/tst_psImageManip.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageManip.c
r1930 r1931 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-09- 29 21:23:30$8 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-09-30 18:47:23 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1291 1291 psImage* fOut = NULL; 1292 1292 psImage* sOut = NULL; 1293 psImage* s32Out = NULL; 1294 psImage* fBiOut = NULL; 1295 psImage* sBiOut = NULL; 1293 1296 psImage* fTruth = NULL; 1294 1297 psImage* sTruth = NULL; 1298 psImage* fBiTruth = NULL; 1299 psImage* sBiTruth = NULL; 1295 1300 int rows = 64; 1296 1301 int cols = 64; 1297 1302 psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32); 1298 1303 psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16); 1304 psImage* s32Img = psImageAlloc(cols,rows,PS_TYPE_S32); 1299 1305 1300 1306 for(int row=0;row<rows;row++) { 1301 1307 psF32* fRow = fImg->data.F32[row]; 1302 1308 psS16* sRow = sImg->data.S16[row]; 1309 psS32* s32Row = s32Img->data.S32[row]; 1303 1310 for (int col=0;col<cols;col++) { 1304 1311 fRow[col] = (psF32)(row)+(psF32)(col)/100.0f; 1305 1312 sRow[col] = row-2*col; 1313 s32Row[col] = row-2*col; 1306 1314 } 1307 1315 } … … 1320 1328 ("temp/sOut.fits") 1321 1329 ; 1330 remove 1331 ("temp/fBiOut.fits") 1332 ; 1333 remove 1334 ("temp/sBiOut.fits"); 1335 ; 1322 1336 int index = 0; 1323 1337 bool fail = false; 1324 1338 for (int rot=-180;rot<=180;rot+=45) { 1325 1339 psImage* oldOut = fOut; 1340 psImage* oldBiOut = fBiOut; 1326 1341 fOut = psImageRotate(fOut,fImg,rot,-1.0,PS_INTERPOLATE_FLAT); 1342 fBiOut = psImageRotate(fBiOut,fImg,rot,-1.0,PS_INTERPOLATE_BILINEAR); 1327 1343 // Verify the returned psImage structure is equal to the input 1328 1344 // parameter out if provided. … … 1331 1347 return 2; 1332 1348 } 1349 if (oldBiOut != NULL && oldBiOut != fBiOut) { 1350 psError(__func__,"the output recycle functionality failed"); 1351 return 4; 1352 } 1333 1353 sOut = psImageRotate(sOut,sImg,rot,-1.0,PS_INTERPOLATE_FLAT); 1354 sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR); 1334 1355 if (! psImageWriteSection(fOut,0,0,0,NULL,index,"temp/fOut.fits") ) { 1335 1356 psError(__func__,"Can not write to temp/fOut.fits, so why continue!?"); … … 1340 1361 return 21; 1341 1362 } 1363 if (! psImageWriteSection(fBiOut,0,0,0,NULL,index,"temp/fBiOut.fits") ) { 1364 psError(__func__,"Can not write to temp/fBiOut.fits, so why continue!?"); 1365 return 40; 1366 } 1367 if (! psImageWriteSection(sBiOut,0,0,0,NULL,index,"temp/sBiOut.fits") ) { 1368 psError(__func__,"Can not write to temp/sBiOut.fits, so why continue!?"); 1369 return 41; 1370 } 1342 1371 1343 1372 // now, let's compare this with the verified file 1344 1373 fTruth = psImageReadSection(fTruth,0,0,0,0,0,NULL,index,"verified/fOut.fits"); 1345 1374 sTruth = psImageReadSection(sTruth,0,0,0,0,0,NULL,index,"verified/sOut.fits"); 1346 1375 fBiTruth = psImageReadSection(fBiTruth,0,0,0,0,0,NULL,index,"verified/fBiOut.fits"); 1376 sBiTruth = psImageReadSection(sBiTruth,0,0,0,0,0,NULL,index,"verified/sBiOut.fits"); 1347 1377 if (fTruth == NULL) { 1348 1378 psError(__func__,"verified psF32 image failed to be read (%d deg. rotation)", … … 1397 1427 1398 1428 1429 if (fBiTruth == NULL) { 1430 psError(__func__,"verified psF32 Bi image failed to be read (%d deg. rotation)", 1431 rot); 1432 fail = true; 1433 } else { 1434 if (fBiTruth->numRows != fBiOut->numRows || fBiTruth->numCols != fBiOut->numCols) { 1435 psError(__func__,"Rotated float image size did not match truth " 1436 "image for %d deg rotation (%dx%d vs %dx%d). BILINEAR", 1437 rot,fBiOut->numCols,fBiOut->numRows,fBiTruth->numCols,fBiTruth->numRows); 1438 fail = true; 1439 } else { 1440 for (int row=0;row<fBiTruth->numRows;row++) { 1441 psF32* truthRow = fBiTruth->data.F32[row]; 1442 psF32* outRow = fBiOut->data.F32[row]; 1443 for (int col=0;col<fBiTruth->numCols;col++) { 1444 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1445 psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR", 1446 outRow[col], truthRow[col],col,row); 1447 fail = true; 1448 } 1449 } 1450 } 1451 } 1452 } 1453 1454 if (sBiTruth == NULL) { 1455 psError(__func__,"verified psS16 image failed to be read " 1456 "(%d deg. rotation) BILINEAR",rot); 1457 fail = true; 1458 } else { 1459 if (sBiTruth->numRows != sBiOut->numRows || 1460 sBiTruth->numCols != sBiOut->numCols) { 1461 psError(__func__,"Rotated short image size did not match truth " 1462 "image for %d deg rotation. BILINEAR",rot); 1463 fail = true; 1464 } else { 1465 for (int row=0;row<sBiTruth->numRows;row++) { 1466 psS16* truthRow = sBiTruth->data.S16[row]; 1467 psS16* outRow = sBiOut->data.S16[row]; 1468 for (int col=0;col<sBiTruth->numCols;col++) { 1469 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1470 psError(__func__,"Short Image mismatch (%d vs %d) " 1471 "at %d,%d. BILINEAR", 1472 outRow[col], truthRow[col],col,row); 1473 fail = true; 1474 } 1475 } 1476 } 1477 } 1478 } 1479 1480 // Verify psImage structure returned is NULL and program execution doesn't stop 1481 // if the input image type is not supported. Do not check for 0 degree rotation 1482 // since an imgae copy will be used. 1483 if (rot != 0 ) { 1484 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error invalid type for rotate."); 1485 s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT); 1486 if( s32Out != NULL ) { 1487 psError(__func__,"psImage returned is not NULL for invalid image type."); 1488 return 5; 1489 } 1490 } 1491 1399 1492 index++; 1400 1493 } … … 1416 1509 } 1417 1510 1511 // Verify the returned psImage structure pointer is null and program 1512 // execution doesn't stop, if the specified interpolation mode is invalid 1513 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid " 1514 "interpolation type."); 1515 fOut = psImageRotate(fOut, fImg, 33, 0, -1); 1516 if (fOut != NULL) { 1517 psError(__func__,"NULL wasn't returned though the interpolation mode " 1518 "is invalid."); 1519 return 4; 1520 } 1521 1418 1522 psFree(sOut); 1419 1523 psFree(fImg); … … 1421 1525 psFree(fTruth); 1422 1526 psFree(sTruth); 1527 psFree(sBiOut); 1528 psFree(fBiTruth); 1529 psFree(sBiTruth); 1530 psFree(fBiOut); 1531 psFree(s32Img); 1532 psFree(s32Out); 1423 1533 1424 1534 return 0; -
trunk/psLib/test/image/verified/tst_psImageManip.stderr
r1926 r1931 212 212 213 213 <DATE><TIME>|<HOST>|I|testImageRotate 214 Following should be an error invalid type for rotate. 215 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 216 Specified psImage type, psS32, is not supported. 217 <DATE><TIME>|<HOST>|I|testImageRotate 218 Following should be an error invalid type for rotate. 219 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 220 Specified psImage type, psS32, is not supported. 221 <DATE><TIME>|<HOST>|I|testImageRotate 222 Following should be an error invalid type for rotate. 223 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 224 Specified psImage type, psS32, is not supported. 225 <DATE><TIME>|<HOST>|I|testImageRotate 226 Following should be an error invalid type for rotate. 227 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 228 Specified psImage type, psS32, is not supported. 229 <DATE><TIME>|<HOST>|I|testImageRotate 230 Following should be an error invalid type for rotate. 231 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 232 Specified psImage type, psS32, is not supported. 233 <DATE><TIME>|<HOST>|I|testImageRotate 234 Following should be an error invalid type for rotate. 235 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 236 Specified psImage type, psS32, is not supported. 237 <DATE><TIME>|<HOST>|I|testImageRotate 238 Following should be an error invalid type for rotate. 239 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 240 Specified psImage type, psS32, is not supported. 241 <DATE><TIME>|<HOST>|I|testImageRotate 242 Following should be an error invalid type for rotate. 243 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 244 Specified psImage type, psS32, is not supported. 245 <DATE><TIME>|<HOST>|I|testImageRotate 214 246 Following should be an error 215 247 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 216 248 Can not operate on a NULL psImage. 249 <DATE><TIME>|<HOST>|I|testImageRotate 250 Following should be an error for invalid interpolation type. 251 <DATE><TIME>|<HOST>|E|psLib.image.psImageRotate 252 Specified interpolation mode, -1, is unsupported. 217 253 218 254 ---> TESTPOINT PASSED (psImage{psImageRotate} | tst_psImageManip.c)
Note:
See TracChangeset
for help on using the changeset viewer.
