Changeset 13351 for trunk/psphot/src/pmFootprint.c
- Timestamp:
- May 11, 2007, 7:42:38 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/pmFootprint.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;
Note:
See TracChangeset
for help on using the changeset viewer.
