Changeset 2915 for trunk/psModules/src/pmNonLinear.c
- Timestamp:
- Jan 5, 2005, 1:25:25 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmNonLinear.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmNonLinear.c
r2857 r2915 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 200 4-12-30 22:22:00$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-01-05 23:25:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 * 12 * XXX: The SDR is silent about image types. Only F32 was implemented. 11 13 * 12 14 */ … … 28 30 *****************************************************************************/ 29 31 30 psReadout *pmNonLinearityPolynomial(psReadout *in ,31 const psPolynomial1D * coeff)32 psReadout *pmNonLinearityPolynomial(psReadout *inputReadout, 33 const psPolynomial1D *input1DPoly) 32 34 { 33 PS_PTR_CHECK_NULL(in ,NULL);34 PS_PTR_CHECK_NULL(in ->image, NULL);35 PS_PTR_CHECK_NULL( coeff,NULL);35 PS_PTR_CHECK_NULL(inputReadout, NULL); 36 PS_PTR_CHECK_NULL(inputReadout->image, NULL); 37 PS_PTR_CHECK_NULL(input1DPoly, NULL); 36 38 37 39 psS32 i; 38 40 psS32 j; 39 41 40 for (i=0;i<(in ->image)->numRows;i++) {41 for (j=0;j<(in ->image)->numCols;j++) {42 (in ->image)->data.F32[i][j] = psPolynomial1DEval(coeff, (in->image)->data.F32[i][j]);42 for (i=0;i<(inputReadout->image)->numRows;i++) { 43 for (j=0;j<(inputReadout->image)->numCols;j++) { 44 (inputReadout->image)->data.F32[i][j] = psPolynomial1DEval(input1DPoly, (inputReadout->image)->data.F32[i][j]); 43 45 } 44 46 } 45 return(in );47 return(inputReadout); 46 48 } 47 49 … … 54 56 be set to the value from outFlux. 55 57 *****************************************************************************/ 56 psReadout *pmNonLinearityLookup(psReadout *in ,58 psReadout *pmNonLinearityLookup(psReadout *inputReadout, 57 59 const psVector *inFlux, 58 60 const psVector *outFlux) 59 61 { 60 PS_PTR_CHECK_NULL(in ,NULL);61 PS_PTR_CHECK_NULL(in ->image,NULL);62 PS_PTR_CHECK_NULL(inputReadout,NULL); 63 PS_PTR_CHECK_NULL(inputReadout->image,NULL); 62 64 PS_PTR_CHECK_NULL(inFlux,NULL); 65 psS32 tableSize = inFlux->n; 66 if (inFlux->n < 2) { 67 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements. Returning inputReadout image."); 68 return(inputReadout); 69 } 63 70 PS_PTR_CHECK_NULL(outFlux,NULL); 71 if (inFlux->n != outFlux->n) { 72 tableSize = PS_MIN(inFlux->n, outFlux->n); 73 psLogMsg(__func__, PS_LOG_WARN, 74 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n); 75 } 64 76 65 77 psS32 i; 66 78 psS32 j; 67 psS32 tableSize = inFlux->n;68 79 psS32 binNum; 69 80 psScalar x; … … 72 83 73 84 x.type.type = PS_TYPE_F32; 74 if (inFlux->n != outFlux->n) { 75 tableSize = PS_MIN(inFlux->n, outFlux->n); 76 psLogMsg(__func__, PS_LOG_WARN, 77 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n); 78 } 79 if (inFlux->n < 2) { 80 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements. Returning in image."); 81 return(in); 82 } 83 for (i=0;i<(in->image)->numRows;i++) { 84 for (j=0;j<(in->image)->numCols;j++) { 85 x.data.F32 = (in->image)->data.F32[i][j]; 85 for (i=0;i<(inputReadout->image)->numRows;i++) { 86 for (j=0;j<(inputReadout->image)->numCols;j++) { 87 x.data.F32 = (inputReadout->image)->data.F32[i][j]; 86 88 87 89 binNum = p_psVectorBinDisect((psVector *)inFlux, &x); … … 89 91 if (binNum == -2) { 90 92 // We get here if x is below the table lookup range. 91 (in ->image)->data.F32[i][j] = outFlux->data.F32[0];93 (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[0]; 92 94 numPixels++; 93 95 94 96 } else if (binNum == -1) { 95 97 // We get here if x is above the table lookup range. 96 (in ->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1];98 (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[tableSize-1]; 97 99 98 100 numPixels++; 99 101 } else if (binNum < -2) { 100 102 // We get here if there was some other problem. 101 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect(). Returning in image.");102 return(in );103 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect(). Returning inputReadout image."); 104 return(inputReadout); 103 105 numPixels++; 104 106 } else { … … 106 108 slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) / 107 109 (inFlux->data.F32[binNum+1] - inFlux->data.F32[binNum]); 108 (in ->image)->data.F32[i][j] = outFlux->data.F32[binNum] +109 ((x.data.F32 - inFlux->data.F32[binNum]) * slope);110 (inputReadout->image)->data.F32[i][j] = outFlux->data.F32[binNum] + 111 ((x.data.F32 - inFlux->data.F32[binNum]) * slope); 110 112 } 111 113 } … … 115 117 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels); 116 118 } 117 return(in );119 return(inputReadout); 118 120 }
Note:
See TracChangeset
for help on using the changeset viewer.
