Changeset 14725
- Timestamp:
- Sep 2, 2007, 10:29:50 AM (19 years ago)
- Location:
- branches/eam_branch_20070830/psLib
- Files:
-
- 5 edited
-
src/imageops/psImageMap.c (modified) (2 diffs)
-
src/imageops/psImagePixelInterpolate.c (modified) (5 diffs)
-
src/imageops/psImagePixelInterpolate.h (modified) (2 diffs)
-
src/pslib_strict.h (modified) (3 diffs)
-
test/imageops/tap_psImageMap.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070830/psLib/src/imageops/psImageMap.c
r14723 r14725 7 7 * @author Eugene Magnier, IfA 8 8 * 9 * @version $Revision: 1.1.2. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-09-02 02:03:58$9 * @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-09-02 20:29:50 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 112 112 } 113 113 114 psImagePixelInterpolatePoor (map->map, mask, 0xff, state);114 psImagePixelInterpolatePoor (map->map, state, mask, 0xff); 115 115 return true; 116 116 } -
branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.c
r14724 r14725 11 11 * @author Eugene Magnier, IfA 12 12 * 13 * @version $Revision: 1.1.2. 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-09-02 02:42:55$13 * @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-09-02 20:29:50 $ 15 15 * 16 16 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 62 62 63 63 // count and mark pixels based on their potential for being interpolated. the input image is 64 // just the mask, the output image is the mask image in which the good, bad, and poor pixels 65 // are marked. 66 // XXX return in the image the state (2nd, which of 4 corners, etc)? 64 // just the mask, the output image contains enum values which define the type of interpolation which 65 // can be performed 67 66 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal) { 68 67 … … 99 98 100 99 // interpolate the poor pixels using the available options 101 bool psImagePixelInterpolatePoor (psImage *image, psImage *mask, psMaskType maskVal, psImage *state) { 100 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal) { 101 102 assert (image->numCols == state->numCols); 103 assert (image->numRows == state->numRows); 104 assert (image->numCols == mask->numCols); 105 assert (image->numRows == mask->numRows); 106 107 // allocate the vectors for the 2nd order fit below 108 psVector *f = psVectorAlloc (9, PS_TYPE_F32); 109 // XXX if we add the weight above, include df 110 // psVector *df = psVectorAlloc (9, PS_TYPE_F32); 111 psVector *x = psVectorAlloc (9, PS_TYPE_F32); 112 psVector *y = psVectorAlloc (9, PS_TYPE_F32); 113 114 // allocate a 2D polynomial to fit a quadratic to the valid neighbor pixels. 115 psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 2, 2); 116 poly->mask[2][2] = 1; 117 poly->mask[2][1] = 1; 118 poly->mask[1][2] = 1; 102 119 103 120 for (int iy = 0; iy < state->numRows; iy++) { … … 114 131 115 132 case PS_IMAGE_INTERPOLATE_CENTER: { 116 // fit a quadratic to the valid neighbor pixels 117 // apply the quadratic to get the poor pixel value 118 psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 2, 2); 119 poly->mask[2][2] = 1; 120 poly->mask[2][1] = 1; 121 poly->mask[1][2] = 1; 122 psVector *f = psVectorAlloc (9, PS_TYPE_F32); 123 psVector *df = psVectorAlloc (9, PS_TYPE_F32); 124 psVector *x = psVectorAlloc (9, PS_TYPE_F32); 125 psVector *y = psVectorAlloc (9, PS_TYPE_F32); 126 133 // XXX is there a fit-image-region function? 127 134 int n = 0; 128 135 for (int jy = -1; jy <= +1; jy++) { 129 // skip invalid pixels (jx < 0, >= Nx), etc136 // skip invalid pixels 130 137 if (jy + iy < 0) { continue; } 131 138 if (jy + iy >= image->numRows) { continue; } 132 139 for (int jx = -1; jx <= +1; jx++) { 133 // skip invalid pixels (jx < 0, >= Nx), etc140 // skip invalid pixels 134 141 if (jx + ix < 0) { continue; } 135 if (jx + ix >= mask->numCols) { continue; }136 / * skip self */142 if (jx + ix >= image->numCols) { continue; } 143 // skip self 137 144 if (!jx && !jy) { continue; } 138 145 // skip masked pixels 139 if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \ 140 f->data.F32[n] = image->data.F32[iy+jy][ix+jx]; 141 // df->data.F32[n] = weight->data.F32[jy][jx]; 146 if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } 142 147 x->data.F32[n] = jx; 143 148 y->data.F32[n] = jy; 149 f->data.F32[n] = image->data.F32[iy+jy][ix+jx]; 150 // df->data.F32[n] = weight->data.F32[iy+jy][ix+jx]; 144 151 n++; 145 152 } 146 153 } 147 // XXXset vector lengths here154 // set vector lengths here 148 155 x->n = n; 149 156 y->n = n; 150 157 f->n = n; 151 158 // df->n = n; 152 psVectorFitPolynomial2D (poly, mask, maskValue, f, df, x, y); 159 // psVectorFitPolynomial2D (poly, NULL, 0xff, f, df, x, y); 160 psVectorFitPolynomial2D (poly, NULL, 0xff, f, NULL, x, y); 161 // apply the fitted quadratic to get the poor pixel value 153 162 image->data.F32[iy][ix] = poly->coeff[0][0]; 154 163 break; } … … 179 188 } 180 189 } 190 191 psFree (x); 192 psFree (y); 193 psFree (f); 194 195 psFree (poly); 181 196 return true; 182 197 } -
branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.h
r14721 r14725 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 20:29:50 $ 11 11 * 12 12 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 32 32 33 33 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal); 34 bool psImagePixelInterpolatePoor (psImage *image, psImage * mask, psMaskType maskVal, psImage *state);34 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal); 35 35 36 36 /// @} -
branches/eam_branch_20070830/psLib/src/pslib_strict.h
r12741 r14725 9 9 * @author Eric Van Alst, MHPCC 10 10 * 11 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 4-04 22:42:02$11 * @version $Revision: 1.29.8.1 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-09-02 20:29:50 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 49 49 #include "psImagePixelExtract.h" 50 50 #include "psImagePixelManip.h" 51 #include "psImagePixelInterpolate.h" 51 52 #include "psImageStats.h" 52 53 #include "psImageStructManip.h" … … 54 55 #include "psImageBinning.h" 55 56 #include "psImageUnbin.h" 57 #include "psImageMap.h" 56 58 57 59 #include "psImageJpeg.h" -
branches/eam_branch_20070830/psLib/test/imageops/tap_psImageMap.c
r14721 r14725 13 13 return (TRUE); 14 14 } 15 16 # define C00 +0.5 17 # define C01 +0.1 18 # define C10 -0.2 15 19 16 20 int main (void) … … 35 39 psVector *f = psVectorAllocEmpty (100, PS_TYPE_F32); 36 40 37 for (int ix = 0; ix < 1000; ix += 25) {38 for (int iy = 0; iy < 1000; iy += 25) {41 for (int ix = 0; ix < 1000; ix += 10) { 42 for (int iy = 0; iy < 1000; iy += 10) { 39 43 x->data.F32[x->n] = ix; 40 44 y->data.F32[y->n] = iy; … … 52 56 53 57 // allocate a map, but we have no field image to supply 54 bool status = psImageMapGenerate (map, x, y, f, 0.1); 58 // XXX this function needs to correct for the mean superpixel position 59 // which is sampled... 60 psImageMapGenerate (map, x, y, f, 0.1); 55 61 psFree (binning); 56 62 57 fprint (stderr, "nGood: %d\n", map->nGood);58 fprint (stderr, "nPoor: %d\n", map->nPoor);59 fprint (stderr, "nBad: %d\n", map->nBad);63 fprintf (stderr, "nGood: %d\n", map->nGood); 64 fprintf (stderr, "nPoor: %d\n", map->nPoor); 65 fprintf (stderr, "nBad: %d\n", map->nBad); 60 66 61 67 SaveImage (NULL, map->map, "map.fits"); … … 71 77 // measure difference between model (map) and data (field) 72 78 for (int ix = 0; ix < map->map->numCols; ix++) { 73 for (int iy = 0; iy < map->map->num; iy++) { 74 int xo = ix*map->binning->nXbin; 75 int yo = iy*map->binning->nYbin; 76 df = field->data.F32[yo][xo] - map->map->data.F32[iy][ix]; 77 fprintf (stderr, "%d %d %f = %f - %f\n", ix, iy, df, field->data.F32[yo][xo], map->map->data.F32[iy][ix]); 79 for (int iy = 0; iy < map->map->numRows; iy++) { 80 81 int xo = (ix + 0.5)*map->binning->nXbin; 82 int yo = (iy + 0.5)*map->binning->nYbin; 83 float df = field->data.F32[yo][xo] - map->map->data.F32[iy][ix]; 84 fprintf (stderr, "%d %d -> %d %d : %f = %f - %f\n", ix, iy, xo, yo, df, field->data.F32[yo][xo], map->map->data.F32[iy][ix]); 78 85 } 79 86 }
Note:
See TracChangeset
for help on using the changeset viewer.
