Changeset 20843 for trunk/magic/remove/src
- Timestamp:
- Nov 25, 2008, 5:24:09 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/magic/remove/src/streakscompare.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/magic/remove/src/streakscompare.c
r20816 r20843 20 20 sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true); 21 21 22 readImage(file1, 0, stage); 23 readImage(file2, 0, stage); 24 25 psImage *image1 = file1->image; 26 psImage *image2 = file2->image; 27 28 if ((image1->numRows != image2->numRows) || (image1->numCols != image2->numCols)) { 29 streaksExit("image sizes do not match\n", PS_EXIT_DATA_ERROR); 22 int ncomponents; 23 if (stage == IPP_STAGE_RAW) { 24 if (file1->nHDU != file2->nHDU) { 25 streaksExit("mages do not have same number of components\n", PS_EXIT_DATA_ERROR); 26 } 27 if (!(psFitsMoveExtNum(file1->fits, 1, true) && psFitsMoveExtNum(file2->fits, 1, true))) { 28 streaksExit("failed to skip primary header of raw file\n", PS_EXIT_DATA_ERROR); 29 } 30 ncomponents = file1->nHDU - 1; 31 } else { 32 ncomponents = 1; 30 33 } 31 34 32 int width = image1->numCols;33 int height = image1->numRows;34 35 int numErrors = 0; 35 for (int y = 0; y < height; y++) { 36 for (int x = 0; x < width; x++) { 37 bool error = false; 36 for (int component = 0; component < ncomponents; component++) { 37 if (component && !(psFitsMoveExtNum(file1->fits, 1, true) 38 && psFitsMoveExtNum(file2->fits, 1, true))) { 39 streaksExit("failed to advance to next extesion\n", PS_EXIT_DATA_ERROR); 40 } 41 readImage(file1, 0, stage); 42 readImage(file2, 0, stage); 38 43 39 double value1 = psImageGet(image1, x, y);40 double value2 = psImageGet(image1, x, y);44 psImage *image1 = file1->image; 45 psImage *image2 = file2->image; 41 46 42 if (!isnan(value1) && !isnan(value2)) { 43 if (value1 != value2) { 44 error = true; 47 // TODO: do more sanity checking. For example check that extname's (if any) match 48 // check for matching image cubes 49 if (image1 && image2) { 50 if ((image1->numRows != image2->numRows) || (image1->numCols != image2->numCols)) { 51 streaksExit("image sizes do not match\n", PS_EXIT_DATA_ERROR); 52 } 53 int width = image1->numCols; 54 int height = image1->numRows; 55 for (int y = 0; y < height; y++) { 56 for (int x = 0; x < width; x++) { 57 bool error = false; 58 59 double value1 = psImageGet(image1, x, y); 60 double value2 = psImageGet(image1, x, y); 61 62 if (!isnan(value1) && !isnan(value2)) { 63 if (value1 != value2) { 64 error = true; 65 } 66 } else { 67 // if one's a nan they had both better be 68 error = ! isnan(value1) && isnan(value2); 69 } 70 71 if (error) { 72 numErrors++; 73 fprintf(stderr, "pixel at %5d %5d do not match %f %f\n", x, y, value1, value2); 74 } 45 75 } 46 } else {47 // if one's a nan they had both better be48 error = ! isnan(value1) && isnan(value2);49 76 } 50 51 if (error) { 52 numErrors++; 53 fprintf(stderr, "pixel at %5d %5d do not match %f %f\n", x, y, value1, value2); 54 } 77 } else if (! ((image1 == NULL) && (image2 == NULL))) { 78 // if one image is null (video extension) both should be 79 streaksExit("image1 null but not image2!", PS_EXIT_DATA_ERROR); 55 80 } 56 81 }
Note:
See TracChangeset
for help on using the changeset viewer.
