Changeset 24382
- Timestamp:
- Jun 11, 2009, 6:09:52 PM (17 years ago)
- Location:
- trunk/magic/remove/src
- Files:
-
- 5 edited
-
Line.c (modified) (1 diff)
-
Line.h (modified) (1 diff)
-
streaksastrom.c (modified) (1 diff)
-
streaksastrom.h (modified) (1 diff)
-
streaksextern.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/magic/remove/src/Line.c
r24380 r24382 225 225 vertices[2].x = numCols; vertices[2].y = numRows; 226 226 vertices[3].x = 0; vertices[3].y = numRows; 227 228 for (i = 0; i < 4 && found < 2; ++i) 229 { 230 boundLine.begin = vertices[i]; 231 boundLine.end = vertices[(i + 1) % 4]; 232 if (LineIntercept (line, &boundLine, &tuple1, &tuple2, false, true)) 233 { 234 if (found == 0) 235 { 236 clipLine.begin = tuple1; 237 ++found; 238 } 239 else if (tuple1.x != clipLine.begin.x || 240 tuple1.y != clipLine.begin.y) 241 { 242 clipLine.end = tuple1; 243 ++found; 244 } 245 } 246 } 247 248 // If two endpoints are found, clip the line 249 250 if (found > 1) 251 { 252 if (clipLine.begin.x <= clipLine.end.x) 253 { 254 line->begin = clipLine.begin; 255 line->end = clipLine.end; 256 } 257 else 258 { 259 line->begin = clipLine.end; 260 line->end = clipLine.begin; 261 } 262 } 263 return found > 1; 264 } 265 266 /** Clip the line between (minX,minY) and (maxX,maxY) 267 268 @param[in,out] line line to be clipped within the bounds 269 @param[in] minX minimum X (columns) for the line 270 @param[in] minY minimum Y (rows) for the line 271 @param[in] maxX maximum X (columns) for the line 272 @param[in] maxY maximum Y (rows) for the line 273 @return true if line overlaps the clip boundaries */ 274 275 bool LineClipFull (Line *line, int minX, int minY, int maxX, int maxY) 276 { 277 unsigned int i, found = 0; 278 Line boundLine, clipLine; 279 strkPt tuple1, tuple2, vertices[4]; 280 vertices[0].x = minX; vertices[0].y = minY; 281 vertices[1].x = maxX; vertices[1].y = minY; 282 vertices[2].x = maxX; vertices[2].y = maxY; 283 vertices[3].x = minX; vertices[3].y = maxY; 227 284 228 285 for (i = 0; i < 4 && found < 2; ++i) -
trunk/magic/remove/src/Line.h
r24344 r24382 21 21 extern bool LineClip (Line *line, int numCols, int numRows); 22 22 23 /** Clip the line between (minX,minY) and (maxX,maxY) 24 25 @param[in,out] line line to be clipped within the bounds 26 @param[in] minX minimum X (columns) for the line 27 @param[in] minY minimum Y (rows) for the line 28 @param[in] maxX maximum X (columns) for the line 29 @param[in] maxY maximum Y (rows) for the line 30 @return true if line overlaps the clip boundaries */ 31 32 extern bool LineClipFull (Line *line, int minX, int minY, int maxX, int maxY); 33 23 34 /** Map a line to an image for its specified width and append as 24 35 a list of pixel positions -
trunk/magic/remove/src/streaksastrom.c
r21437 r24382 150 150 151 151 bool 152 SkyToLocal(strkPt *outPt, strkAstrom *astrom, double ra, double dec) 153 { 154 // generate a local project using the RA, DEC of the 0,0 pixel of the chip as the 155 // projection center with the same plate scale as the nominal TP->Sky astrometry. 156 157 pmFPA *fpa = (pmFPA *) astrom->fpa; 158 pmChip *chip = (pmChip *) astrom->chip; 159 160 // find the RA,DEC coords of the 0,0 pixel for this chip: 161 162 psPlane ptTP; 163 psSphere ptSky; 164 165 ptSky.r = ra; 166 ptSky.d = dec; 167 ptSky.rErr = 0.0; 168 ptSky.dErr = 0.0; 169 170 psProject(&ptTP, &ptSky, fpa->toSky); 171 172 outPt->x = ptTP.x; 173 outPt->y = ptTP.y; 174 175 return true; 176 } 177 178 bool 179 LocalToSky(strkPt *outPt, strkAstrom *astrom, strkPt *inPt) 180 { 181 // generate a local project using the RA, DEC of the 0,0 pixel of the chip as the 182 // projection center with the same plate scale as the nominal TP->Sky astrometry. 183 184 pmFPA *fpa = (pmFPA *) astrom->fpa; 185 pmChip *chip = (pmChip *) astrom->chip; 186 187 // find the RA,DEC coords of the 0,0 pixel for this chip: 188 189 psPlane ptTP; 190 psSphere ptSky; 191 192 ptTP.x = inPt->x; 193 ptTP.y = inPt->y; 194 ptTP.xErr = 0.0; 195 ptTP.yErr = 0.0; 196 197 psDeproject(&ptSky, &ptTP, fpa->toSky); 198 199 outPt->x = ptSky.r; 200 outPt->y = ptSky.d; 201 202 return true; 203 } 204 205 bool 206 componentBounds(int *minX, int *minY, int *maxX, int *maxY, strkAstrom *astrom, int numCols, int numRows) 207 { 208 // find the bounds of the (padded) chip region in tangent-plane coordinates 209 210 pmFPA *fpa = (pmFPA *) astrom->fpa; 211 pmChip *chip = (pmChip *) astrom->chip; 212 213 psPlane ptCH, ptFP, TPo, TPx, TPy; 214 215 // coordinate of the chip center: 216 ptCH.x = 0.5*numCols; 217 ptCH.y = 0.5*numRows; 218 psPlaneTransformApply(&ptFP, chip->toFPA, &ptCH); 219 psPlaneTransformApply(&TPo, fpa->toTPA, &ptFP); 220 221 // coordinate of the chip center + dX/2: 222 ptCH.x = numCols; 223 ptCH.y = 0.5*numRows; 224 psPlaneTransformApply(&ptFP, chip->toFPA, &ptCH); 225 psPlaneTransformApply(&TPx, fpa->toTPA, &ptFP); 226 227 // coordinate of the chip center + dY/2: 228 ptCH.x = 0.5*numCols; 229 ptCH.y = numRows; 230 psPlaneTransformApply(&ptFP, chip->toFPA, &ptCH); 231 psPlaneTransformApply(&TPy, fpa->toTPA, &ptFP); 232 233 // half-lengths of the two sides in tangent-plane coords: 234 double xSize = hypot (TPx.x - TPo.x, TPx.y - TPo.y); 235 double ySize = hypot (TPy.x - TPo.x, TPy.y - TPo.y); 236 double radius = hypot (xSize, ySize); 237 238 // define the region encompassed by the radius with some padding: 239 *minX = TPo.x - 1.1*radius; 240 *minY = TPo.y - 1.1*radius; 241 *maxX = TPo.x + 1.1*radius; 242 *maxY = TPo.y + 1.1*radius; 243 244 return true; 245 } 246 247 bool 152 248 skyToCell(strkPt *outPt, strkAstrom *astrom, double ra, double dec) 153 249 { -
trunk/magic/remove/src/streaksastrom.h
r21155 r24382 32 32 extern void linearizeTransforms(strkAstrom *astrom); 33 33 34 extern bool SkyToLocal(strkPt *outPt, strkAstrom *astrom, double ra, double dec); 35 extern bool LocalToSky(strkPt *outPt, strkAstrom *astrom, strkPt *inPt); 36 extern bool componentBounds(int *minX, int *minY, int *maxX, int *maxY, strkAstrom *astrom, int numCols, int numRows); 37 34 38 #endif // STREAKS_ASTROM_H -
trunk/magic/remove/src/streaksextern.c
r24344 r24382 36 36 StreakPixels *pixels = psArrayAllocEmpty (1024); 37 37 int streaksOnComponent = 0; 38 39 int minX, minY, maxX, maxY; 40 41 // find the chip dimensions in the tangent-plane coordinates (length of hypotenuse) 42 componentBounds (&minX, &minY, &maxX, &maxY, astrom, numCols, numRows); 43 38 44 for (i = 0; i != streaks->size; ++i) 39 45 { … … 41 47 42 48 line.width = streaks->list[i].width; 43 if (skyToCell (&line.begin, astrom, 44 streaks->list[i].ra1, streaks->list[i].dec1) && 45 skyToCell (&line.end, astrom, 46 streaks->list[i].ra2, streaks->list[i].dec2) && 49 50 /* Use tangent plane coordinates to narrow down the ra,dec range of the line closer to 51 * the chip boundaries. Use these new ra,dec positions to generate the line on the 52 * chip using the full non-linear astrometry */ 53 54 // project the ends of the line using a linear projection centered on the chip center: 55 Line full; 56 SkyToLocal (&full.begin, astrom, streaks->list[i].ra1, streaks->list[i].dec1); 57 SkyToLocal (&full.end, astrom, streaks->list[i].ra2, streaks->list[i].dec2); 58 59 // clip the line to a square box with diameter = hypotenuse of the chip image centerd 60 // on the chip center in tangent-plane coordinates. skip the rest of this streak if 61 // the line does not intersect this region 62 if (!LineClipFull (&full, minX, minY, maxX, maxY)) { 63 continue; 64 } 65 66 // convert the end points back into ra, dec pairs: 67 strkPt sky1, sky2; 68 LocalToSky (&sky1, astrom, &full.begin); 69 LocalToSky (&sky2, astrom, &full.end); 70 71 if (skyToCell (&line.begin, astrom, sky1.x, sky1.y) && 72 skyToCell (&line.end, astrom, sky2.x, sky2.y) && 47 73 LineClip (&line, numCols, numRows)) 48 74 {
Note:
See TracChangeset
for help on using the changeset viewer.
