Changeset 34470
- Timestamp:
- Sep 25, 2012, 5:33:33 PM (14 years ago)
- Location:
- branches/czw_branch/20120906
- Files:
-
- 6 edited
-
psLib/src/imageops/psImageInterpolate.c (modified) (1 diff)
-
pswarp/src/pswarp.h (modified) (1 diff)
-
pswarp/src/pswarpLoop.c (modified) (1 diff)
-
pswarp/src/pswarpMapGrid.c (modified) (1 diff)
-
pswarp/src/pswarpTransformReadout.c (modified) (1 diff)
-
pswarp/src/pswarpTransformTile.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c
r34442 r34470 947 947 int yl,yh; 948 948 const psImage *image = interp->image; // Image to interpolate 949 // const psImage *mask = interp->mask; // Mask to interpolate950 const psImage *variance = interp->variance; // Variance to interpolate951 949 952 950 xl = floor(x); 953 951 if (xl < 0) { xl = 0; } 954 952 if (xl >= image->numCols) {xl = image->numCols - 1; } 953 //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; } 955 954 xh = xl + 1; 956 955 if (xh >= image->numCols) {xh = image->numCols - 1; } 956 //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; } 957 // 957 958 yl = floor(y); 958 959 if (yl < 0) { yl = 0; } 959 960 if (yl >= image->numRows) {yl = image->numRows - 1; } 961 //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; } 962 // 960 963 yh = yl + 1; 961 964 if (yh >= image->numRows) {yh = image->numRows - 1; } 962 if (varianceValue && variance) { 963 u1 = (xh - x) * variance->data.F32[yl][xl] + (x - xl) * variance->data.F32[yl][xh]; 964 u2 = (xh - x) * variance->data.F32[yh][xl] + (x - xl) * variance->data.F32[yh][xh]; 965 966 *varianceValue = (yh - y) * u1 + (y - yl) * u2; 967 } 968 #if 0 969 if (maskValue && mask) { 970 u1 = (xh - x) * mask->data.F32[yl][xl] + (x - xl) * mask->data.F32[yl][xh]; 971 u2 = (xh - x) * mask->data.F32[yh][xl] + (x - xl) * mask->data.F32[yh][xh]; 972 973 maskValue = (yh - y) * u1 + (y - yl) * u2; 974 } 975 #endif 965 //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; } 966 // 976 967 if (imageValue && image) { 977 968 if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) { -
branches/czw_branch/20120906/pswarp/src/pswarp.h
r34411 r34470 94 94 95 95 pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix); 96 pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix); 96 97 bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY); 97 98 bool pswarpMapGridCoordRange (pswarpMapGrid *grid, int gridX, int gridY, psPlane *min, psPlane *max); -
branches/czw_branch/20120906/pswarp/src/pswarpLoop.c
r34449 r34470 804 804 805 805 fprintf(stderr,"Transforming Readout!\n"); 806 807 psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", true); 806 808 pswarpTransformReadout(output, readout, config); 809 psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", false); 807 810 808 811 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { -
branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c
r31878 r34470 52 52 return grid; 53 53 } 54 /** 55 * pswarpMapGridFromImageForBackground builds a set (a grid) of locally-linear maps which convert the source 56 * coordinates (src) to destination coordinates (dest). we construct a grid with superpixel 57 * spacing of nXpix, nYpix. The transformation for each grid cell is valid for the superpixel. 58 * The grid over-fills the source image so every source image pixel is guaranteed to have a map. 59 */ 60 pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) { 61 62 int i, ni; 63 int j, nj; 64 65 // start counting from the center of the superpixels 66 double xMin = 0.5*nXpix; 67 double yMin = 0.5*nYpix; 68 69 // the map is defined for coordinates in the image parent frame. 70 int Nx = src->image->numCols + src->image->col0; 71 int Ny = src->image->numRows + src->image->row0; 72 73 // always allocate an extra superpixel to handle spillover 74 int nXpts = (int)(Nx / nXpix) + 1; 75 int nYpts = (int)(Ny / nYpix) + 1; 76 77 // create the grid of maps 78 pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts); 79 80 // measure the map for the center of each superpixel 81 for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) { 82 for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) { 83 pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j); 84 /* grid->maps[ni][nj]->Xo += (13.0 * 400.0 - 4846.0) / 2.0; */ 85 /* grid->maps[ni][nj]->Yo += (13.0 * 400.0 - 4868.0) / 2.0; */ 86 } 87 } 88 89 grid->nXpix = nXpix; 90 grid->nYpix = nYpix; 91 grid->xMin = xMin; 92 grid->yMin = yMin; 93 return grid; 94 } 54 95 55 96 /** -
branches/czw_branch/20120906/pswarp/src/pswarpTransformReadout.c
r34442 r34470 60 60 // pswarpMapGridFromImage builds a set of locally-linear maps which convert the 61 61 // output coordinates to input coordinates 62 pswarpMapGrid *grid = pswarpMapGridFromImage(input, output, nGridX, nGridY); 63 62 pswarpMapGrid *grid; 63 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) { 64 grid = pswarpMapGridFromImageForBackground(input, output, nGridX, nGridY); 65 } 66 else { 67 grid = pswarpMapGridFromImage(input, output, nGridX, nGridY); 68 } 64 69 // XXX optionally modify the grid based on this result and force the maxError < XXX 65 70 double maxError = pswarpMapGridMaxError(grid); // Maximum (positional) error from using grid -
branches/czw_branch/20120906/pswarp/src/pswarpTransformTile.c
r34442 r34470 86 86 for (int y = yMin; y < yMax; y++) { 87 87 for (int x = xMin; x < xMax; x++) { 88 /* if ((x == 931)||(x == 717)||(x == 924)) { */89 /* /\* if ((y == 1348)||(y == 1249)||(y == 1081)) { *\/ */90 /* /\* fprintf(stderr,"BEcause: %d %d [%d %d %d %d]\n",x,y,yMin,yMax,xMin,xMax); *\/ */91 /* /\* } *\/ */92 /* } */93 if (((x == 931)&&(y == 1348))||94 ((x == 717)&&(y == 1249))||95 ((x == 924)&&(y == 1081))) {96 psTrace("pswarp",3,"TT: A\n");97 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);98 99 }100 101 88 // Only transform those pixels requested 102 89 if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) { 103 90 continue; 104 91 } 105 if (((x == 931)&&(y == 1348))||106 ((x == 717)&&(y == 1249))||107 ((x == 924)&&(y == 1081))) {108 psTrace("pswarp",3,"TT: B\n");109 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);110 111 }112 113 92 // pswarpMapApply converts the output coordinate (x,y) to the input coordinate. 114 93 // both are in the parent frames of the input and output images. 115 94 double xIn, yIn; // Input pixel coordinates 116 95 pswarpMapApply(&xIn, &yIn, map, x + 0.5, y + 0.5); 117 if (((x == 931)&&(y == 1348))||118 ((x == 717)&&(y == 1249))||119 ((x == 924)&&(y == 1081))) {120 psTrace("pswarp",3,"TT: Ct\n");121 psTrace("pswarp",3,"TT: %d %d %d %d %g %g %d %d\n",xMin,xMax,yMin,yMax,xIn,yIn,inNumCols,inNumRows);122 96 123 } 97 if (args->interp->mode == 8) { 98 xIn += 177.0 / 400.0; 99 yIn += 166.0 / 400.0; 124 100 101 if ((xIn > inNumCols - 177.0/ 400.0)|| 102 (yIn > inNumRows - 166.0/ 400.0)|| 103 (xIn < 177.0/ 400.0)|| 104 (yIn < 166.0/ 400.0) 105 106 ) { 107 fprintf(stderr,"\n"); 108 continue; 109 } 110 } 111 125 112 if (xIn < 0 || xIn >= inNumCols || yIn < 0 || yIn >= inNumRows) { 126 113 continue; 127 114 } 128 if (((x == 931)&&(y == 1348))||129 ((x == 717)&&(y == 1249))||130 ((x == 924)&&(y == 1081))) {131 psTrace("pswarp",3,"TT: C\n");132 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);133 134 }135 115 136 116 // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates … … 144 124 int xOut = x - outCol0, yOut = y - outRow0; ///< Position on output image 145 125 146 if ((xIn >= args->interp->image->numCols - 1)|| 147 (yIn >= args->interp->image->numRows - 1)) { 148 imageValue = NAN; 126 if (((xOut % 500) == 0)&&((yOut % 500) == 0)) { 127 fprintf(stderr,"%d %d %g %g %d %d (%d %d %d %d) %g %g %g\n", 128 x,y,xIn,yIn,xOut,yOut,xMin,xMax,yMin,yMax,imageValue, 129 (4846 - 400 * (12)) / 2.0, 130 (4868 - 400 * (12)) / 2.0 131 132 ); 149 133 } 134 135 /* if ((xIn >= args->interp->image->numCols - 1)|| */ 136 /* (yIn >= args->interp->image->numRows - 1)) { */ 137 /* imageValue = NAN; */ 138 /* } */ 150 139 if (outImageData) { 151 140 outImageData[yOut][xOut] = imageValue * jacobian; … … 159 148 160 149 goodPixels++; 161 162 if ((x == 931)||(x == 717)||(x == 924)) {163 if ((y == 1348)||(y == 1249)||(y == 1081)) {164 psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld %g %g %g %g\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,165 args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp,166 0.0,0.0,0.0,0.0);167 /* inImage->data.F32[(int) yIn][(int) xIn], */168 /* inImage->data.F32[(int) yIn+1][(int) xIn], */169 /* inImage->data.F32[(int) yIn+1][(int) xIn+1], */170 /* inImage->data.F32[(int) yIn][(int) xIn+1]); */171 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);172 }173 }174 175 if (((xOut == 931)&&(yOut == 1348))||176 ((xOut == 717)&&(yOut == 1249))||177 ((xOut == 924)&&(yOut == 1081))) {178 psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld %g %g %g %g\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,179 args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp,180 0.0,0.0,0.0,0.0);181 /* inImage->data.F32[(int) yIn][(int) xIn], */182 /* inImage->data.F32[(int) yIn+1][(int) xIn], */183 /* inImage->data.F32[(int) yIn+1][(int) xIn+1], */184 /* inImage->data.F32[(int) yIn][(int) xIn+1]); */185 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);186 187 }188 if ((xOut == 443)&&(yOut == 659)) {189 psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,190 args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp);191 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);192 193 }194 if ((xOut == 524)&&(yOut == 576)) {195 psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,196 args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp);197 psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);198 199 }200 150 } 201 151 }
Note:
See TracChangeset
for help on using the changeset viewer.
