Changeset 14859
- Timestamp:
- Sep 15, 2007, 9:43:43 AM (19 years ago)
- Location:
- branches/eam_branch_20070830/psLib
- Files:
-
- 3 added
- 7 edited
-
src/imageops/Makefile.am (modified) (1 diff)
-
src/imageops/psImageBinning.c (modified) (2 diffs)
-
src/imageops/psImageBinning.h (modified) (2 diffs)
-
src/imageops/psImageMap.h (modified) (2 diffs)
-
src/imageops/psImageMapFit.c (added)
-
src/imageops/psImageUnbin.c (modified) (3 diffs)
-
src/imageops/psImageUnbin.h (modified) (2 diffs)
-
test/imageops/Makefile.am (modified) (1 diff)
-
test/imageops/tap_psImageMapFit.c (added)
-
test/imageops/tap_psImageMapFit2.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/imageops/Makefile.am
r14721 r14859 16 16 psImageBinning.c \ 17 17 psImageMap.c \ 18 psImageMapFit.c \ 18 19 psImagePixelInterpolate.c \ 19 20 psImageUnbin.c -
branches/eam_branch_20070830/psLib/src/imageops/psImageBinning.c
r14773 r14859 8 8 * @author Eugene Magnier, IfA 9 9 * 10 * @version $Revision: 1.2.8. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-09- 07 20:19:02$10 * @version $Revision: 1.2.8.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-09-15 19:43:43 $ 12 12 * 13 13 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 148 148 149 149 // convert the fine coordinate to the ruff coordinate 150 float psImageBinningGetRuffX (psImageBinning *binning, float xFine) { 151 float xRuff = (xFine - binning->nXskip)/binning->nXbin; 150 double psImageBinningGetRuffX (const psImageBinning *binning, const double xFine) { 151 152 PS_ASSERT_INT_POSITIVE(binning->nXbin, NAN); 153 PS_ASSERT_INT_POSITIVE(binning->nYbin, NAN); 154 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nXskip, binning->nXbin, NAN); 155 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nYskip, binning->nYbin, NAN); 156 157 double xRuff = (xFine - binning->nXskip)/binning->nXbin; 152 158 return xRuff; 153 159 } 154 float psImageBinningGetRuffY (psImageBinning *binning, float yFine) { 155 float yRuff = (yFine - binning->nYskip)/binning->nYbin; 160 double psImageBinningGetRuffY (const psImageBinning *binning, const double yFine) { 161 162 PS_ASSERT_INT_POSITIVE(binning->nXbin, NAN); 163 PS_ASSERT_INT_POSITIVE(binning->nYbin, NAN); 164 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nXskip, binning->nXbin, NAN); 165 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nYskip, binning->nYbin, NAN); 166 167 double yRuff = (yFine - binning->nYskip)/binning->nYbin; 156 168 return yRuff; 157 169 } 158 170 159 171 // convert the ruff coordinate to the fine coordinate 160 float psImageBinningGetFineX (psImageBinning *binning, float xRuff) { 161 float xFine = xRuff * binning->nXbin + binning->nXskip; 172 double psImageBinningGetFineX (const psImageBinning *binning, const double xRuff) { 173 174 PS_ASSERT_INT_POSITIVE(binning->nXbin, NAN); 175 PS_ASSERT_INT_POSITIVE(binning->nYbin, NAN); 176 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nXskip, binning->nXbin, NAN); 177 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nYskip, binning->nYbin, NAN); 178 179 double xFine = xRuff * binning->nXbin + binning->nXskip; 162 180 return xFine; 163 181 } 164 float psImageBinningGetFineY (psImageBinning *binning, float yRuff) { 165 float yFine = yRuff * binning->nYbin + binning->nYskip; 182 double psImageBinningGetFineY (const psImageBinning *binning, const double yRuff) { 183 184 PS_ASSERT_INT_POSITIVE(binning->nXbin, NAN); 185 PS_ASSERT_INT_POSITIVE(binning->nYbin, NAN); 186 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nXskip, binning->nXbin, NAN); 187 PS_ASSERT_INT_LESS_THAN_OR_EQUAL(binning->nYskip, binning->nYbin, NAN); 188 189 double yFine = yRuff * binning->nYbin + binning->nYskip; 166 190 return yFine; 167 191 } -
branches/eam_branch_20070830/psLib/src/imageops/psImageBinning.h
r14773 r14859 8 8 * @author Eugene Magnier, IfA 9 9 * 10 * @version $Revision: 1.2.2. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-09- 07 20:19:05$10 * @version $Revision: 1.2.2.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-09-15 19:43:43 $ 12 12 * 13 13 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 51 51 psRegion psImageBinningSetRuffRegion (psImageBinning *binning, psRegion fineRegion); 52 52 53 float psImageBinningGetRuffX (psImageBinning *binning, floatxFine);54 float psImageBinningGetRuffY (psImageBinning *binning, floatyFine);55 float psImageBinningGetFineX (psImageBinning *binning, floatxRuff);56 float psImageBinningGetFineY (psImageBinning *binning, floatyRuff);53 double psImageBinningGetRuffX (const psImageBinning *binning, const double xFine); 54 double psImageBinningGetRuffY (const psImageBinning *binning, const double yFine); 55 double psImageBinningGetFineX (const psImageBinning *binning, const double xRuff); 56 double psImageBinningGetFineY (const psImageBinning *binning, const double yRuff); 57 57 58 58 /// @} -
branches/eam_branch_20070830/psLib/src/imageops/psImageMap.h
r14774 r14859 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-09- 07 20:19:35$9 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-15 19:43:43 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 48 48 psVector *psImageMapEvalVector (psImageMap *map, psVector *x, psVector *y); 49 49 50 // fit the image map to a set of points 51 bool psImageMapFit (psImageMap *map, psVector *x, psVector *y, psVector *f, psVector *df); 52 50 53 /// @} 51 54 #endif // #ifndef PS_IMAGE_MAP_H -
branches/eam_branch_20070830/psLib/src/imageops/psImageUnbin.c
r12588 r14859 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $10 * @date $Date: 2007-0 3-27 02:43:22$9 * @version $Revision: 1.7.8.1 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-15 19:43:43 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 205 205 * N.b. This code only works for the central part of the image; the edge 206 206 * cases should be added 207 208 * XXXX this is bilinear interpolation, but written sub-optimally 209 * XXXX this function should be taking float input coordinates!!! 207 210 */ 208 211 double psImageUnbinPixel(const int ix, const int iy, // desired Unbinned point (parent coords) … … 249 252 return Vxs + (Vxe - Vxs)*(ix - xs)/DX; // value at [iy][ix] 250 253 } 254 255 double psImageUnbinPixel_V2(const double xFine, const double yFine, // desired Unbinned point (parent coords) 256 const psImage *in, // binned image 257 const psImageBinning *binning) //!< Overhang 258 { 259 PS_ASSERT_IMAGE_NON_NULL(in, NAN); 260 assert (in->type.type == PS_TYPE_F32); 261 262 const float xRuff = psImageBinningGetRuffX (binning, xFine); 263 const float yRuff = psImageBinningGetRuffY (binning, yFine); 264 265 const double value = psImageInterpolatePixelBilinear (xRuff, yRuff, in); 266 267 return value; 268 } 269 270 // fast & simple API to interpolate to a subpixel position using bilinear interpolation 271 // x,y in parent image coordinates (pixel centers at 0.5, 0.5) 272 double psImageInterpolatePixelBilinear (const double xIn, const double yIn, const psImage *in) { 273 274 PS_ASSERT_PTR_NON_NULL(in, PS_ERR_BAD_PARAMETER_VALUE); 275 assert (in->type.type == PS_TYPE_F32); 276 277 const double x = xIn - in->col0; 278 const double y = yIn - in->row0; 279 280 // allow extrapolation to edge of valid pixels, but not beyond 281 if ((x < 0) || (x >= in->numCols) || (y < 0) || (y >= in->numRows)) { 282 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Point (%f,%f) lies outside binned image", x, y); 283 return NAN; 284 } 285 286 // handle edge cases with extrapolation 287 288 const int ix = x - 0.5; // index of reference pixel 289 const int iy = y - 0.5; // index of reference pixel 290 291 const int Xs = PS_MAX (PS_MIN (ix, in->numCols - 2), 0); 292 const int Ys = PS_MAX (PS_MIN (iy, in->numRows - 2), 0); 293 294 const int Xe = Xs + 1; 295 const int Ye = Ys + 1; 296 297 // dx,dy range from 0.0 to 1.0 for interpolated pixels, and -0.5 to 1.5 for extrapolation 298 const double dx = x - 0.5 - Xs; 299 const double dy = y - 0.5 - Ys; 300 301 const double rx = 1.0 - dx; 302 const double ry = 1.0 - dy; 303 304 // Vxy 305 double V00 = in->data.F32[Ys][Xs]; 306 double V10 = in->data.F32[Ys][Xe]; 307 double V01 = in->data.F32[Ye][Xs]; 308 double V11 = in->data.F32[Ye][Xe]; 309 310 // bilinear interpolation 311 const double value = V00*rx*ry + V10*rx*dy + V01*dx*ry + V11*dx*dy; 312 313 return value; 314 } 315 316 -
branches/eam_branch_20070830/psLib/src/imageops/psImageUnbin.h
r12588 r14859 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * $Revision: 1.4 $ $Name: not supported by cvs2svn $9 * $Date: 2007-0 3-27 02:43:22$8 * $Revision: 1.4.8.1 $ $Name: not supported by cvs2svn $ 9 * $Date: 2007-09-15 19:43:43 $ 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 28 28 ); 29 29 30 double psImageUnbinPixel_V2(const double xFine, const double yFine, // desired Unbinned point (parent coords) 31 const psImage *in, // binned image 32 const psImageBinning *binning //!< Overhang 33 ); 34 35 double psImageInterpolatePixelBilinear (const double xIn, const double yIn, const psImage *in); 36 30 37 /// @} 31 38 #endif -
branches/eam_branch_20070830/psLib/test/imageops/Makefile.am
r14721 r14859 23 23 tap_psImageInterpolate2 \ 24 24 tap_psImageMap \ 25 tap_psImageMapFit \ 25 26 tap_psImageMaskOps 26 27
Note:
See TracChangeset
for help on using the changeset viewer.
