Changeset 5435 for trunk/psModules/src/detrend
- Timestamp:
- Oct 20, 2005, 1:06:24 PM (21 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 4 edited
-
pmFlatField.c (modified) (4 diffs)
-
pmFlatField.h (modified) (2 diffs)
-
pmNonLinear.c (modified) (2 diffs)
-
pmNonLinear.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFlatField.c
r5170 r5435 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-28 20:43:52$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-10-20 23:06:24 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 39 39 40 bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat) 40 bool pmFlatField( 41 pmReadout *in, 42 const pmReadout *flat) 41 43 { 42 44 // XXX: Not sure if this is correct. Must consult with IfA. 43 PS_ASSERT_PTR_NON_NULL( mask, false);45 PS_ASSERT_PTR_NON_NULL(in->mask, false); 44 46 int i = 0; 45 47 int j = 0; … … 56 58 // Check for nulls 57 59 if (in == NULL) { 58 return true; // Readout m ay not have data in it60 return true; // Readout might have data in it 59 61 } else if(flat==NULL) { 60 62 psError( PS_ERR_BAD_PARAMETER_NULL, true, … … 74 76 return false; 75 77 } 76 inMask = mask->image;78 inMask = in->mask; 77 79 78 80 // Check input image and its mask are not larger than flat image -
trunk/psModules/src/detrend/pmFlatField.h
r5170 r5435 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-28 20:43:52$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-10-20 23:06:24 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 37 37 bool pmFlatField( 38 38 pmReadout *in, ///< Readout with input image 39 pmReadout *mask, ///< Input image mask40 39 const pmReadout *flat ///< Readout with flat image 41 40 ); -
trunk/psModules/src/detrend/pmNonLinear.c
r5170 r5435 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005- 09-28 20:43:52$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-10-20 23:06:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 56 56 inFluxe, and the corresponding value in outFlux. The image pixel will then 57 57 be set to the value from outFlux. 58 59 XXX: Must assert that filename exists. This should probably happen in 60 the lookup files. 58 61 *****************************************************************************/ 59 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout, 60 const psVector *inFlux, 61 const psVector *outFlux) 62 pmReadout *pmNonLinearityLookup( 63 pmReadout *inputReadout, 64 const char *filename 65 ) 62 66 { 63 67 PS_ASSERT_PTR_NON_NULL(inputReadout,NULL); 64 68 PS_ASSERT_PTR_NON_NULL(inputReadout->image,NULL); 65 69 PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, NULL); 66 PS_ASSERT_PTR_NON_NULL(inFlux,NULL); 67 if (inFlux->n < 2) { 68 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements. Returning inputReadout image."); 69 return(inputReadout); 70 } 71 PS_ASSERT_PTR_NON_NULL(outFlux,NULL); 72 psS32 tableSize = inFlux->n; 73 if (inFlux->n != outFlux->n) { 74 tableSize = PS_MIN(inFlux->n, outFlux->n); 70 psLookupTable *tmpLT = psLookupTableAlloc(filename, "%f %f", 0); 71 psS32 numLines = psLookupTableRead(tmpLT); 72 psS32 numPixels = 0; 73 if (numLines < 2) { 75 74 psLogMsg(__func__, PS_LOG_WARN, 76 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n); 77 } 78 PS_ASSERT_VECTOR_TYPE(inFlux, PS_TYPE_F32, NULL); 79 PS_ASSERT_VECTOR_TYPE(outFlux, PS_TYPE_F32, NULL); 80 81 psS32 i; 82 psS32 j; 83 psS32 binNum; 84 psScalar x; 85 psS32 numPixels = 0; 86 psF32 slope; 87 88 x.type.type = PS_TYPE_F32; 89 for (i=0;i<inputReadout->image->numRows;i++) { 90 for (j=0;j<inputReadout->image->numCols;j++) { 91 x.data.F32 = inputReadout->image->data.F32[i][j]; 92 binNum = p_psVectorBinDisect((psVector *)inFlux, &x); 93 94 if (binNum == -2) { 95 // We get here if x is below the table lookup range. 96 inputReadout->image->data.F32[i][j] = outFlux->data.F32[0]; 97 numPixels++; 98 99 } else if (binNum == -1) { 100 // We get here if x is above the table lookup range. 101 inputReadout->image->data.F32[i][j] = outFlux->data.F32[tableSize-1]; 102 numPixels++; 103 104 } else if (binNum < -2) { 105 // We get here if there was some other problem. 106 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect(). Returning inputReadout image."); 107 return(inputReadout); 108 numPixels++; 109 } else { 110 // Perform linear interpolation. 111 slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) / 112 (inFlux->data.F32[binNum+1] - inFlux->data.F32[binNum]); 113 inputReadout->image->data.F32[i][j] = outFlux->data.F32[binNum] + 114 ((x.data.F32 - inFlux->data.F32[binNum]) * slope); 75 "WARNING: Lookup Table is too small. Returning original pmReadout.\n"); 76 } else { 77 for (psS32 i=0;i<inputReadout->image->numRows;i++) { 78 for (psS32 j=0;j<inputReadout->image->numCols;j++) { 79 psF64 tmpD = psLookupTableInterpolate(tmpLT, inputReadout->image->data.F32[i][j], 1); 80 if (!isnan(tmpD)) { 81 inputReadout->image->data.F32[i][j] = tmpD; 82 } else { 83 numPixels++; 84 } 115 85 } 116 86 } 87 if (numPixels > 0) { 88 psLogMsg(__func__, PS_LOG_WARN, 89 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels); 90 } 117 91 } 118 if (numPixels > 0) { 119 psLogMsg(__func__, PS_LOG_WARN, 120 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels); 121 } 92 122 93 return(inputReadout); 123 94 } -
trunk/psModules/src/detrend/pmNonLinear.h
r5170 r5435 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005- 09-28 20:43:52$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-10-20 23:06:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmAstrometry.h" 19 19 20 pmReadout *pmNonLinearityPolynomial(pmReadout *in, 21 const psPolynomial1D *coeff); 20 pmReadout *pmNonLinearityPolynomial( 21 pmReadout *in, 22 const psPolynomial1D *coeff 23 ); 22 24 23 pmReadout *pmNonLinearityLookup(pmReadout *in, 24 const psVector *inFlux, 25 const psVector *outFlux); 25 pmReadout *pmNonLinearityLookup( 26 pmReadout *in, 27 const char *filename 28 ); 26 29 27 30 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
