Changeset 18867
- Timestamp:
- Aug 1, 2008, 3:29:09 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmFootprintArrayGrow.c
r18828 r18867 3 3 * @author RHL, Princeton & IfA; EAM, IfA 4 4 * 5 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2008-08-0 1 00:00:17$5 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2008-08-02 01:29:09 $ 7 7 * Copyright 2006 Institute for Astronomy, University of Hawaii 8 8 */ … … 26 26 */ 27 27 psArray *pmFootprintArrayGrow(const psArray *footprints, // footprints to grow 28 int r) {// how much to grow each footprint28 int r) { // how much to grow each footprint 29 29 assert (footprints->n == 0 || pmFootprintTest(footprints->data[0])); 30 30 31 31 psTimerStart ("grow"); 32 32 33 if (footprints->n == 0) { // we don't know the size of the footprint's region34 return psArrayAlloc(0);33 if (footprints->n == 0) { // we don't know the size of the footprint's region 34 return psArrayAlloc(0); 35 35 } 36 36 /* … … 41 41 psLogMsg ("psphot", PS_LOG_DETAIL, "set footprint array IDs: %f sec\n", psTimerMark ("grow")); 42 42 43 #if 1 44 // Use a separable convolution: should be faster 45 idImage = (psImage*)psBinaryOp(idImage, idImage, "MAX", psScalarAlloc(1, PS_TYPE_S32)); 46 psImage *maskImage = psImageCopy(NULL, idImage, PS_TYPE_MASK); 47 psImage *grownIdImage = psImageConvolveMask(NULL, maskImage, 0xff, 0xff, -1, 1, -1, 1); 48 psFree(maskImage); 49 #else 43 50 if (r <= 0) { 44 r = 1;// r == 1 => no grow51 r = 1; // r == 1 => no grow 45 52 } 46 53 psKernel *circle = psKernelAlloc(-r, r, -r, r); 47 54 assert (circle->image->numRows == 2*r + 1 && circle->image->numCols == circle->image->numRows); 48 55 for (int i = 0; i <= r; i++) { 49 for (int j = 0; j <= r; j++) {50 if (i*i + j*j <= r*r) {51 circle->kernel[i][j] = 52 circle->kernel[i][-j] = 53 circle->kernel[-i][j] = 54 circle->kernel[-i][-j] = 1;55 }56 }56 for (int j = 0; j <= r; j++) { 57 if (i*i + j*j <= r*r) { 58 circle->kernel[i][j] = 59 circle->kernel[i][-j] = 60 circle->kernel[-i][j] = 61 circle->kernel[-i][-j] = 1; 62 } 63 } 57 64 } 58 65 59 # if (USE_FFTS_TO_CONVOLVE) 66 # if (USE_FFTS_TO_CONVOLVE) 60 67 psImage *f32ImageIn = psImageCopy (NULL, idImage, PS_TYPE_F32); 61 68 psImage *f32ImageOut = psImageConvolveFFT(NULL, f32ImageIn, NULL, 0, circle); … … 63 70 psFree (f32ImageIn); 64 71 psFree (f32ImageOut); 65 # else72 #else 66 73 psImage *grownIdImage = psImageConvolveDirect(NULL, idImage, circle); // Here's the actual grow step 67 # endif 74 #endif // USE_FFTS_TO_CONVOLVE 75 psFree(circle); 76 #endif // Don't bother at all 77 78 psFree(idImage); 68 79 69 80 psLogMsg ("psphot", PS_LOG_DETAIL, "convolved with grow disc: %f sec\n", psTimerMark ("grow")); 70 psFree(circle);71 81 72 82 psArray *grown = pmFootprintsFind(grownIdImage, 0.5, 1); // and here we rebuild the grown footprints … … 74 84 75 85 assert (grown != NULL); 76 psFree(idImage);77 86 psFree(grownIdImage); 78 87 … … 88 97 89 98 return grown; 90 99 91 100 } 92 101
Note:
See TracChangeset
for help on using the changeset viewer.
