Changeset 4216 for trunk/psphot/src/LocalSky.c
- Timestamp:
- Jun 12, 2005, 3:49:21 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/LocalSky.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/LocalSky.c
r4215 r4216 1 1 # include "psphot.h" 2 2 3 psSource *pmSourceDefinePixels(const psImageData *imdata, 4 const psPeak *peak, 5 psF32 Radius) 3 bool pmSourceDefinePixels(psSource *mySource, 4 const psImageData *imdata, 5 psF32 x, 6 psF32 y, 7 psF32 Radius) 6 8 { 7 // XXX EAM : EndRow is *exclusive* of pixel region (ie, last pixel + 1) 8 psS32 SubImageStartRow = PS_MAX (0, peak->y - Radius); 9 psS32 SubImageEndRow = PS_MIN (image->numRows, peak->y + Radius + 1); 10 psS32 SubImageStartCol = PS_MAX (0, peak->x - Radius); 11 psS32 SubImageEndCol = PS_MIN (image->numCols, peak->x + Radius + 1); 9 // Grab a subimage of the original image of size (2 * outerRadius). 10 srcRegion = psRegionSquare (x, y, Radius); 11 srcRegion = psRegionForImage (srcRegion, imdata->image); 12 12 13 // Grab a subimage of the original image of size (2 * outerRadius). 14 psImage *subImage = psImageSubset(imdata->image, 15 SubImageStartCol, 16 SubImageStartRow, 17 SubImageEndCol, 18 SubImageEndRow); 13 psImage *subImage = psImageSubset(imdata->image, srcRegion); 14 psImage *subImageMask = psImageSubset(imdata->mask, srcRegion); 15 psImage *subImageNoise = psImageSubset(imdata->noise, srcRegion); 19 16 20 psImage *subImageMask = psImageSubset(imdata->mask,21 SubImageStartCol,22 SubImageStartRow,23 SubImageEndCol,24 SubImageEndRow);25 26 psImage *subImageNoise = psImageSubset(imdata->noise,27 SubImageStartCol,28 SubImageStartRow,29 SubImageEndCol,30 SubImageEndRow);31 32 psSource *mySource = pmSourceAlloc();33 mySource->peak = peak;34 17 mySource->pixels = subImage; 35 18 mySource->mask = subImageMask; … … 49 32 psImage *peak = source->peak; 50 33 51 // Loop through the subimage, mask off pixels in the inner square. 52 // this uses a static mask value of 0x08 53 psS32 StartCol = PS_MAX (0, peak->x - mask->col0 - Radius); 54 psS32 StartRow = PS_MAX (0, peak->y - mask->row0 - Radius); 55 psS32 EndCol = PS_MIN (mask->numCols, peak->x - mask->col0 + Radius + 1); 56 psS32 EndRow = PS_MIN (mask->numRows, peak->y - mask->row0 + Radius + 1); 57 for (psS32 row = StartRow; row < EndRow; row++) { 58 for (psS32 col = StartCol; col < EndCol; col++) { 59 mask->data.U8[row][col] |= 0x80; 60 } 61 } 34 srcRegion = psRegionSquare (peak->x, peak->y, Radius); 35 srcRegion = psRegionForImage (srcRegion, imdata->mask); 36 psImageMaskRegion (imdata->mask, region, OR, 0x80); 62 37 63 38 psStats *myStats = psStatsAlloc(statsOptions); 64 39 myStats = psImageStats(myStats, image, mask, 0xff); 65 66 // clear the mask on the inner pixels 67 for (psS32 row = StartRow; row < EndRow; row++) { 68 for (psS32 col = StartCol; col < EndCol; col++) { 69 mask->data.U8[row][col] &= 0x7f; 70 } 71 } 40 psImageMaskRegion (imdata->mask, region, AND, 0x7f); 72 41 73 42 mySource->moments = pmMomentsAlloc(); … … 79 48 } 80 49 81 // set mask pixels within the circle 82 bool psImageMaskCircle(psImage *mask, 83 psF32 x, 84 psF32 y, 85 psF32 radius, 86 int maskValue) 87 { 88 // XXX EAM : for the circle to stay on the image 89 // XXX EAM : EndRow is *exclusive* of pixel region (ie, last pixel + 1) 90 psS32 SubImageStartRow = PS_MAX (0, x + mask->row0 - radiusS32); 91 psS32 SubImageEndRow = PS_MIN (mask->numRows, SubImageCenterRow + radiusS32 + 1); 92 psS32 SubImageStartCol = PS_MAX (0, SubImageCenterCol - radiusS32); 93 psS32 SubImageEndCol = PS_MIN (mask->numCols, SubImageCenterCol + radiusS32 + 1); 94 95 // Loop through the subimage mask, set maskValue bits 96 for (psS32 row = 0 ; row < source->mask->numRows; row++) { 97 for (psS32 col = 0 ; col < source->mask->numCols; col++) { 98 99 if (CheckRadius2((psF32) radiusS32, 100 (psF32) radiusS32, 101 radius, 102 (psF32) col, 103 (psF32) row)) { 104 source->mask->data.U8[row][col] = 0; 105 } else { 106 source->mask->data.U8[row][col] = 1; 107 } 108 } 109 } 110 return(true); 50 // define a square region centered on the given coordinate 51 psRegion *psRegionSquare (psF32 x, psF32 y, psF32 radius) { 52 region = psRegionAlloc (x - Radius, y - Radius, x + Radius + 1, y + Radius + 1); 53 return (region); 111 54 } 112
Note:
See TracChangeset
for help on using the changeset viewer.
