Changeset 13351
- Timestamp:
- May 11, 2007, 7:42:38 AM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 3 edited
-
pmFootprint.c (modified) (2 diffs)
-
pmFootprint.h (modified) (1 diff)
-
psphotReadout.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/pmFootprint.c
r13349 r13351 863 863 /************************************************************************************************************/ 864 864 /* 865 * Grow a psArray of pmFootprints isotropically by r pixels, returning a new psArray of new pmFootprints 866 */ 867 psArray *pmGrowFootprintArray(const psArray *footprints, // footprints to grow 868 int r) { // how much to grow each footprint 869 assert (footprints->n == 0 || pmIsFootprint(footprints->data[0])); 870 871 if (footprints->n == 0) { // we don't know the size of the footprint's region 872 return psArrayAlloc(0); 873 } 874 /* 875 * We'll insert the footprints into an image, then convolve with a disk, 876 * then extract a footprint from the result --- this is magically what we want. 877 */ 878 psImage *idImage = pmSetFootprintArrayIDs(footprints, true); 879 if (r <= 0) { 880 r = 1; // r == 1 => no grow 881 } 882 psKernel *circle = psKernelAlloc(-r, r, -r, r); 883 assert (circle->image->numRows == 2*r + 1 && circle->image->numCols == circle->image->numRows); 884 for (int i = 0; i <= r; i++) { 885 for (int j = 0; j <= r; j++) { 886 if (i*i + j*j <= r*r) { 887 circle->kernel[i][j] = 888 circle->kernel[i][-j] = 889 circle->kernel[-i][j] = 890 circle->kernel[-i][-j] = 1; 891 } 892 } 893 } 894 895 psImage *grownIdImage = psImageConvolveDirect(idImage, circle); 896 psFree(circle); 897 898 psArray *grown = pmFindFootprints(grownIdImage, 0.5, 1); 899 assert (grown != NULL); 900 psFree(idImage); psFree(grownIdImage); 901 /* 902 * Now assign the peaks appropriately. We could do this more efficiently 903 * using idImage (which we just freed), but this is easy and probably fast enough 904 */ 905 const psArray *peaks = pmFootprintArrayToPeaks(footprints); 906 pmPeaksAssignToFootprints(grown, peaks); 907 psFree((psArray *)peaks); 908 909 return grown; 910 911 } 912 913 /************************************************************************************************************/ 914 /* 865 915 * Merge together two psArrays of pmFootprints neither of which is damaged. 866 916 * … … 911 961 /* 912 962 * Now assign the peaks appropriately. We could do this more efficiently 913 * using idImage (which we just freed), but this is easy an yprobably fast enough963 * using idImage (which we just freed), but this is easy and probably fast enough 914 964 */ 915 965 const psArray *peaks; -
trunk/psphot/src/pmFootprint.h
r13236 r13351 35 35 int row, int col); 36 36 37 psArray *pmGrowFootprintArray(const psArray *footprints, int r); 37 38 psArray *pmMergeFootprintArrays(const psArray *footprints1, const psArray *footprints2); 38 39 -
trunk/psphot/src/psphotReadout.c
r13348 r13351 65 65 if (useFootprints) { 66 66 psArray *footprints = psphotFindPeaks (readout, recipe, useFootprints, 1); 67 int growRadius = psMetadataLookupS32(None, recipe, "FOOTPRINT_GROW_RADIUS"); 68 if (growRadius > 0) { 69 psArray *tmp = pmGrowFootprintArray(footprints, growRadius); 70 psFree(footprints); 71 footprints = tmp; 72 } 73 67 74 peaks = pmFootprintArrayToPeaks(footprints); 68 75 psFree(footprints); … … 170 177 psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2); 171 178 179 int growRadius = psMetadataLookupS32(None, recipe, "FOOTPRINT_GROW_RADIUS_2"); 180 if (growRadius > 0) { 181 psArray *tmp = pmGrowFootprintArray(newFootprints, growRadius); 182 psFree(newFootprints); 183 newFootprints = tmp; 184 } 185 172 186 psphotCullPeaks(readout->image, readout->weight, recipe, newFootprints); 173 187
Note:
See TracChangeset
for help on using the changeset viewer.
