Changeset 14723
- Timestamp:
- Sep 1, 2007, 4:03:58 PM (19 years ago)
- Location:
- branches/eam_branch_20070830/psLib/src
- Files:
-
- 5 edited
-
imageops/psImageMap.c (modified) (5 diffs)
-
imageops/psImageMap.h (modified) (3 diffs)
-
imageops/psImagePixelInterpolate.c (modified) (4 diffs)
-
math/psStats.c (modified) (3 diffs)
-
math/psStats.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/imageops/psImageMap.c
r14721 r14723 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-09-0 1 00:41:01$9 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-02 02:03:58 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 22 22 #include "psAssert.h" 23 23 #include "psRegion.h" 24 #include "psVector.h" 24 25 #include "psImage.h" 26 #include "psStats.h" 25 27 #include "psImageBinning.h" 26 28 #include "psImageMap.h" 29 #include "psImagePixelInterpolate.h" 27 30 28 31 static void psImageMapFree(psImageMap *map) { … … 57 60 58 61 // generate a psImageMap (or NULL) with the given number of superpixels in X and Y 59 psImageMap *psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) { 60 61 int nBad; 62 int nPoor; 62 bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) { 63 63 64 64 psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK); … … 84 84 } 85 85 86 for (int iy = 0; iy < map->map->numRows; iy++) { 87 for (int ix = 0; ix < map->map->numCols; ix++) { 86 int Nx = map->map->numCols; 87 int Ny = map->map->numRows; 88 for (int iy = 0; iy < Ny; iy++) { 89 for (int ix = 0; ix < Nx; ix++) { 88 90 89 91 // select the vector 90 92 psVector *vector = vectors->data[ix + iy*Nx]; 91 93 94 // reset the stats to avoid contamination from the previous loop 95 psStatsInit (map->stats); 96 92 97 // get the value 93 if (psVectorStats ( stats, vector, NULL, NULL, 0)) {98 if (psVectorStats (map->stats, vector, NULL, NULL, 0)) { 94 99 mask->data.U8[iy][ix] = 0; 95 map->map->data.F32[iy][ix] = stats->robustMedian; // XXX select correct stats 100 // XXX ensure only one option is selected, or save both position and width 101 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options); 96 102 } else { 97 103 mask->data.U8[iy][ix] = 1; … … 102 108 psImage *state = psImagePixelInterpolateState (&map->nBad, &map->nPoor, mask, 0xff); 103 109 map->nGood = mask->numCols * mask->numRows - map->nBad - map->nPoor; 104 if ( nBad > badFrac * mask->numCols * mask->numRows) {105 return false :110 if (map->nBad > badFrac * mask->numCols * mask->numRows) { 111 return false; 106 112 } 107 113 -
branches/eam_branch_20070830/psLib/src/imageops/psImageMap.h
r14721 r14723 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-09-0 1 00:41:01$9 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-02 02:03:58 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 27 27 psImage *map; 28 28 psImage *field; 29 psImage Map*binning;29 psImageBinning *binning; 30 30 int nBad; 31 31 int nPoor; … … 36 36 37 37 // generate a psImageMap (or NULL) with the given number of superpixels in X and Y 38 psImageMap *psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac);38 bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac); 39 39 40 40 /// @} -
branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.c
r14721 r14723 11 11 * @author Eugene Magnier, IfA 12 12 * 13 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-09-0 1 00:41:01$13 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-09-02 02:03:58 $ 15 15 * 16 16 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 32 32 #include "psAssert.h" 33 33 #include "psString.h" 34 #include "psPolynomial.h" 35 #include "psPolynomialUtils.h" 34 36 #include "psImage.h" 35 37 #include "psImageInterpolate.h" 38 #include "psImagePixelInterpolate.h" 36 39 37 40 # define PS_IMAGE_ITER_STATE(XS,XE,YS,YE,N_MIN,TYPE) \ 38 41 nGood = 0; \ 39 for ( jy = YS; jy <= YE; jy++) { \40 / / stick to pixels in image grid\42 for (int jy = YS; jy <= YE; jy++) { \ 43 /* stick to pixels in image grid */ \ 41 44 if (jy + iy < 0) { continue; } \ 42 45 if (jy + iy >= mask->numRows) { continue; } \ 43 for ( jx = XS; jx <= XE; jx++) { \44 / / stick to pixels in image grid\46 for (int jx = XS; jx <= XE; jx++) { \ 47 /* stick to pixels in image grid */ \ 45 48 if (jx + ix < 0) { continue; } \ 46 49 if (jx + ix >= mask->numCols) { continue; } \ 47 / / do not test self\50 /* do not test self */ \ 48 51 if (!jx && jy) { continue; } \ 49 52 if (mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal) { continue; } \ … … 66 69 psImageInit (result, 0); 67 70 68 intnPoor = 0;69 intnBad = 0;71 *nPoor = 0; 72 *nBad = 0; 70 73 71 74 for (int iy = 0; iy < mask->numRows; iy++) { … … 103 106 case PS_IMAGE_INTERPOLATE_GOOD: 104 107 // skip the good pixels 105 continue;108 break; 106 109 107 110 case PS_IMAGE_INTERPOLATE_BAD: 108 111 // skip the bad pixels 109 continue;112 break; 110 113 111 case PS_IMAGE_INTERPOLATE_CENTER: 112 // fit a quadratic to the valid neighbor pixels113 // apply the quadratic to get the poor pixel value114 psPolynomial2D *poly = psImageBicubeFit (image, mask, maskVal, ix, iy);115 image->data.F32[iy][ix] = poly->coeff[0][0];116 continue;114 case PS_IMAGE_INTERPOLATE_CENTER: { 115 // fit a quadratic to the valid neighbor pixels 116 // apply the quadratic to get the poor pixel value 117 psPolynomial2D *poly = psImageBicubeFit (image, mask, maskVal, ix, iy); 118 image->data.F32[iy][ix] = poly->coeff[0][0]; 119 break; } 117 120 118 case PS_IMAGE_INTERPOLATE_LL: 119 // fit a plane to the valid neighbor pixels 120 // apply the plane to get the poor pixel value 121 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 1); 122 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0] + poly->coeff[0][1]; 123 continue; 124 case PS_IMAGE_INTERPOLATE_LR: 125 // fit a plane to the valid neighbor pixels 126 // apply the plane to get the poor pixel value 127 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 1); 128 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[0][1]; 129 continue; 130 case PS_IMAGE_INTERPOLATE_UL: 131 // fit a plane to the valid neighbor pixels 132 // apply the plane to get the poor pixel value 133 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 0); 134 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0]; 135 continue; 136 case PS_IMAGE_INTERPOLATE_UR: 137 // fit a plane to the valid neighbor pixels 138 // apply the plane to get the poor pixel value 139 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 0); 140 image->data.F32[iy][ix] = poly->coeff[0][0]; 141 continue; 121 case PS_IMAGE_INTERPOLATE_LL: { 122 // fit a plane to the valid neighbor pixels 123 // apply the plane to get the poor pixel value 124 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 1); 125 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0] + poly->coeff[0][1]; 126 break; } 127 128 case PS_IMAGE_INTERPOLATE_LR: { 129 // fit a plane to the valid neighbor pixels 130 // apply the plane to get the poor pixel value 131 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 1); 132 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[0][1]; 133 break; } 134 135 case PS_IMAGE_INTERPOLATE_UL: { 136 // fit a plane to the valid neighbor pixels 137 // apply the plane to get the poor pixel value 138 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 0); 139 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0]; 140 break; } 141 142 case PS_IMAGE_INTERPOLATE_UR: { 143 // fit a plane to the valid neighbor pixels 144 // apply the plane to get the poor pixel value 145 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 0); 146 image->data.F32[iy][ix] = poly->coeff[0][0]; 147 break; } 148 149 default: 150 psAbort("impossible case in __func__"); 142 151 } 143 152 } 144 153 } 145 return result;154 return true; 146 155 } 147 156 157 -
branches/eam_branch_20070830/psLib/src/math/psStats.c
r14440 r14723 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.215 $ $Name: not supported by cvs2svn $16 * @date $Date: 2007-0 8-08 21:31:42$15 * @version $Revision: 1.215.2.1 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-09-02 02:03:58 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii … … 1748 1748 psStats *stats = p_psAlloc(file, lineno, func, sizeof(psStats)); 1749 1749 psMemSetDeallocator(stats, (psFreeFunc)statsFree); 1750 1751 // set initial, default values 1752 psStatsInit (stats); 1753 1754 // these values are can be set as desired by the user. they are not affected by 1755 // psStatsInit 1756 stats->clipSigma = 3.0; 1757 stats->clipIter = 3; 1758 stats->nSubsample = 100000; 1759 stats->options = options; 1760 1761 psTrace(TRACE, 3, "---- %s() end ----\n", __func__); 1762 return stats; 1763 } 1764 1765 // reset the values which are output, and which may be used from one psStats stage to the next 1766 void psStatsInit(psStats *stats) 1767 { 1750 1768 stats->sampleMean = NAN; 1751 1769 stats->sampleMedian = NAN; … … 1766 1784 stats->clippedStdev = NAN; 1767 1785 stats->clippedNvalues = -1; // XXX: This is never used 1768 stats->clipSigma = 3.0;1769 stats->clipIter = 3;1770 1786 stats->min = NAN; 1771 1787 stats->max = NAN; 1772 1788 stats->binsize = NAN; 1773 stats->nSubsample = 100000; 1774 stats->options = options; 1775 1776 psTrace(TRACE, 3, "---- %s() end ----\n", __func__); 1777 return stats; 1789 return; 1778 1790 } 1779 1791 -
branches/eam_branch_20070830/psLib/src/math/psStats.h
r14452 r14723 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.62 $ $Name: not supported by cvs2svn $11 * @date $Date: 2007-0 8-09 01:40:07$10 * @version $Revision: 1.62.2.1 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-09-02 02:03:58 $ 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 13 13 */ … … 131 131 ); 132 132 133 // reset the values which are output, and which may be used from one psStats stage to the next 134 void psStatsInit(psStats *stats); 135 133 136 // Get the statistics option from a string 134 137 psStatsOptions psStatsOptionFromString(const char *string);
Note:
See TracChangeset
for help on using the changeset viewer.
