Changeset 25875 for trunk/ppImage/src/ppImageParityFlip.c
- Timestamp:
- Oct 18, 2009, 10:42:16 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageParityFlip.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageParityFlip.c
r24228 r25875 10 10 item->data.TYPE = VALUE; } 11 11 12 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view) { 12 // flip the image to have 'native' (detector) or 'raw' (readout) orientation 13 bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view, bool native) { 13 14 14 15 bool status; 16 int xParity, yParity; 17 int xParityRaw, yParityRaw; 18 int xParityTarget, yParityTarget; 15 19 16 20 if (!options->applyParity) return true; … … 21 25 pmCell *cell = readout->parent; 22 26 23 int xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 24 if (!status || (xParity != -1 && xParity != 1)) { 25 psWarning("CELL.XPARITY is not set for the input cell; assuming 1.\n"); 26 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1); 27 xParity = 1; 28 } 29 int yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 30 if (!status || (yParity != -1 && yParity != 1)) { 31 psWarning("CELL.YPARITY is not set for the input cell; assuming 1.\n"); 32 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1); 33 yParity = 1; 27 if (native) { 28 // find the current (raw) parity 29 xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 30 if (!status || (xParity != -1 && xParity != 1)) { 31 psWarning("CELL.XPARITY is not set for the input cell; assuming 1.\n"); 32 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1); 33 xParity = 1; 34 } 35 yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 36 if (!status || (yParity != -1 && yParity != 1)) { 37 psWarning("CELL.YPARITY is not set for the input cell; assuming 1.\n"); 38 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1); 39 yParity = 1; 40 } 41 42 // save the raw parity 43 psMetadataAddS32 (cell->concepts, PS_LIST_TAIL, "CELL.XPARITY.RAW", PS_META_REPLACE, "original parity", xParity); 44 psMetadataAddS32 (cell->concepts, PS_LIST_TAIL, "CELL.YPARITY.RAW", PS_META_REPLACE, "original parity", yParity); 45 46 xParityTarget = 1; 47 yParityTarget = 1; 48 } else { 49 // find the current (native) parity 50 xParity = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY"); 51 psAssert (status, "CELL.XPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 52 53 yParity = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY"); 54 psAssert (status, "CELL.YPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 55 56 // find the raw parity 57 xParityRaw = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY.RAW"); 58 psAssert (status, "CELL.XPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 59 60 yParityRaw = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY.RAW"); 61 psAssert (status, "CELL.YPARITY not set : cannot call ppImageParityFlip (native = false) without first calling it with native = true"); 62 63 xParityTarget = xParityRaw; 64 yParityTarget = yParityRaw; 34 65 } 35 66 36 67 // for this case, nothing to be done: 37 if ((xParity == 1) && (yParity == 1)) return true;38 68 if ((xParity == xParityTarget) && (yParity == yParityTarget)) return true; 69 39 70 psImage *image = readout->image; 40 71 psImage *var = readout->variance; … … 55 86 56 87 // the three cases (+1,-1), (-1,+1), (-1,-1) should be handled independently 57 if ((xParity == -1) && (yParity == +1)) { 88 89 // flip only in x-direction 90 if ((xParity != xParityTarget) && (yParity == yParityTarget)) { 58 91 for (int iy = 0; iy < Ny; iy++) { 59 92 for (int ix = 0; ix < Nx; ix++) { … … 71 104 } 72 105 } 73 if ((xParity == +1) && (yParity == -1)) { 106 // flip only in y-direction 107 if ((xParity == xParityTarget) && (yParity != yParityTarget)) { 74 108 for (int iy = 0; iy < Ny/2; iy++) { 75 109 memcpy (imrow, image->data.F32[iy], Nx*sizeof(psF32)); … … 90 124 } 91 125 } 92 if ((xParity == -1) && (yParity == -1)) { 126 // flip in both directions 127 if ((xParity != xParityTarget) && (yParity != yParityTarget)) { 93 128 for (int iy = 0; iy < Ny/2; iy++) { 94 129 for (int ix = 0; ix < Nx; ix++) { … … 118 153 } 119 154 120 // FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, 1);121 // FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, 1);155 FIX_CONCEPT(cell->concepts, "CELL.XPARITY", S32, xParityTarget); 156 FIX_CONCEPT(cell->concepts, "CELL.YPARITY", S32, yParityTarget); 122 157 123 158 psFree (imrow);
Note:
See TracChangeset
for help on using the changeset viewer.
