Changeset 8480
- Timestamp:
- Aug 22, 2006, 2:48:04 PM (20 years ago)
- Location:
- trunk/pois
- Files:
-
- 1 added
- 17 edited
-
GPL.txt (added)
-
src/errorCodes-skl.c (modified) (1 diff)
-
src/pois.c (modified) (1 diff)
-
src/poisAddPenalty.c (modified) (3 diffs)
-
src/poisCalculateDeviations.c (modified) (1 diff)
-
src/poisCalculateEquation.c (modified) (1 diff)
-
src/poisCheckKernel.c (modified) (1 diff)
-
src/poisConvolveImage.c (modified) (1 diff)
-
src/poisExtractKernel.c (modified) (1 diff)
-
src/poisFindStamps.c (modified) (1 diff)
-
src/poisKernelBasisFunctions.c (modified) (1 diff)
-
src/poisMakeMask.c (modified) (4 diffs)
-
src/poisMaskOps.c (modified) (5 diffs)
-
src/poisParseConfig.c (modified) (6 diffs)
-
src/poisReadStamps.c (modified) (1 diff)
-
src/poisRejectStamps.c (modified) (1 diff)
-
src/poisSolveEquation.c (modified) (1 diff)
-
src/poisStamp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/errorCodes-skl.c
r3809 r8480 24 24 for (int i = 0; i < nerror; i++) { 25 25 psErrorDescription *tmp = psAlloc(sizeof(psErrorDescription)); 26 p_psMemSetPersistent(tmp, true);26 p_psMemSetPersistent(tmp, true); 27 27 *tmp = errors[i]; 28 28 psErrorRegister(tmp, 1); 29 psFree(tmp); /* it's on the internal list */29 psFree(tmp); /* it's on the internal list */ 30 30 } 31 nerror = 0; // don't register more than once31 nerror = 0; // don't register more than once 32 32 } -
trunk/pois/src/pois.c
r8077 r8480 1 /* 2 * POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction 3 * 4 * Attempts to fit for a general convolution kernel that will match the PSFs between two images. 5 * 6 */ 1 // POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction 2 // 3 // Attempts to fit for a general convolution kernel that will match the PSFs between two images. 4 // 5 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License as published by 9 // the Free Software Foundation; either version 2 of the License, or 10 // (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 20 8 21 #include <stdio.h> -
trunk/pois/src/poisAddPenalty.c
r3792 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> … … 4 20 #include "pois.h" 5 21 6 void poisAddPenalty(psImage *matrix, // The matrix7 psVector *vector,// The vector8 float penalty,// Penalty value9 const psArray *kernels, // Kernel basis functions10 const poisConfig *config // Configuration22 void poisAddPenalty(psImage *matrix, // The matrix 23 psVector *vector, // The vector 24 float penalty, // Penalty value 25 const psArray *kernels, // Kernel basis functions 26 const poisConfig *config // Configuration 11 27 ) 12 28 { … … 25 41 26 42 for (int j = 0; j < numKernels; j++) { 27 poisKernelBasis *kernel = kernels->data[j];28 if (kernel->xOrder == 0 && kernel->yOrder == 0) {29 for (int k = j + 1; k < numKernels; k++) {30 poisKernelBasis *compare = kernels->data[k];31 if (compare->xOrder == 0 && compare->yOrder == 0 &&32 (compare->u == kernel->u + 1 || compare->u == kernel->u - 1 ||33 compare->v == kernel->v + 1 || compare->v == kernel->v - 1)) {34 matrix->data.F64[j][k] -= penalty;35 matrix->data.F64[k][j] -= penalty;36 }37 }38 }39 40 if (abs(kernel->u) == config->xKernel) {41 if (abs(kernel->v) == config->yKernel) {42 vector->data.F64[j] -= 3.0 * penalty;43 } else {44 vector->data.F64[j] -= 5.0 * penalty;45 }46 } else {47 if (abs(kernel->v) == config->yKernel) {48 vector->data.F64[j] -= 5.0 * penalty;49 } else {50 vector->data.F64[j] -= 8.0 * penalty;51 }52 }53 43 poisKernelBasis *kernel = kernels->data[j]; 44 if (kernel->xOrder == 0 && kernel->yOrder == 0) { 45 for (int k = j + 1; k < numKernels; k++) { 46 poisKernelBasis *compare = kernels->data[k]; 47 if (compare->xOrder == 0 && compare->yOrder == 0 && 48 (compare->u == kernel->u + 1 || compare->u == kernel->u - 1 || 49 compare->v == kernel->v + 1 || compare->v == kernel->v - 1)) { 50 matrix->data.F64[j][k] -= penalty; 51 matrix->data.F64[k][j] -= penalty; 52 } 53 } 54 } 55 56 if (abs(kernel->u) == config->xKernel) { 57 if (abs(kernel->v) == config->yKernel) { 58 vector->data.F64[j] -= 3.0 * penalty; 59 } else { 60 vector->data.F64[j] -= 5.0 * penalty; 61 } 62 } else { 63 if (abs(kernel->v) == config->yKernel) { 64 vector->data.F64[j] -= 5.0 * penalty; 65 } else { 66 vector->data.F64[j] -= 8.0 * penalty; 67 } 68 } 69 54 70 } 55 71 -
trunk/pois/src/poisCalculateDeviations.c
r7075 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisCalculateEquation.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <math.h> -
trunk/pois/src/poisCheckKernel.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include "pslib.h" -
trunk/pois/src/poisConvolveImage.c
r6452 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisExtractKernel.c
r6452 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisFindStamps.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisKernelBasisFunctions.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisMakeMask.c
r5717 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> … … 7 23 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 8 24 9 psImage *poisMakeMask(psImage *mask, // Mask to update, or NULL10 const psImage *refImage, // Reference image11 const psImage *inImage, // Input image12 const poisConfig *config // Configuration25 psImage *poisMakeMask(psImage *mask, // Mask to update, or NULL 26 const psImage *refImage, // Reference image 27 const psImage *inImage, // Input image 28 const poisConfig *config // Configuration 13 29 ) 14 30 { … … 20 36 assert(config); 21 37 22 int nx = config->xImage; // Size in x23 int ny = config->yImage; // Size in y38 int nx = config->xImage; // Size in x 39 int ny = config->yImage; // Size in y 24 40 25 41 psTrace("pois.makeMask", 5, "Creating mask: %dx%d\n", nx, ny); … … 27 43 // Allocate the mask image, if necessary 28 44 if (mask == NULL) { 29 mask = psImageAlloc(nx, ny, PS_TYPE_U8);30 // Initialise to zero31 for (int j = 0; j < ny; j++) {32 for (int i = 0; i < nx; i++) {33 mask->data.U8[j][i] = POIS_MASK_OK;34 }35 }45 mask = psImageAlloc(nx, ny, PS_TYPE_U8); 46 // Initialise to zero 47 for (int j = 0; j < ny; j++) { 48 for (int i = 0; i < nx; i++) { 49 mask->data.U8[j][i] = POIS_MASK_OK; 50 } 51 } 36 52 } 37 53 38 54 // Iterate over the images 39 55 for (int y = config->yKernel; y < ny - config->yKernel; y++) { 40 for (int x = config->xKernel; x < nx - config->xKernel; x++) {41 // Mask all around something that's saturated in the reference, since it gets convolved42 // But only mask single pixel in the input image, since it doesn't get convolved43 if (refImage->data.F32[y][x] >= config->refSat || refImage->data.F32[y][x] <= config->refBad ||44 isnan(refImage->data.F32[y][x])) {45 mask->data.U8[y][x] |= POIS_MASK_BAD;46 int xlow = MAX(0, x - config->xKernel);47 int xhigh = MIN(nx, x + config->xKernel);48 int ylow = MAX(0, y - config->yKernel);49 int yhigh = MIN(ny, y + config->yKernel);50 for (int v = ylow; v <= yhigh; v++) {51 for (int u = xlow; u <= xhigh; u++) {52 mask->data.U8[v][u] |= POIS_MASK_NEAR_BAD;53 }54 }55 } else if (inImage->data.F32[y][x] >= config->inSat || inImage->data.F32[y][x] <= config->inBad ||56 isnan(inImage->data.F32[y][x])) {57 mask->data.U8[y][x] |= POIS_MASK_BAD;58 }59 }56 for (int x = config->xKernel; x < nx - config->xKernel; x++) { 57 // Mask all around something that's saturated in the reference, since it gets convolved 58 // But only mask single pixel in the input image, since it doesn't get convolved 59 if (refImage->data.F32[y][x] >= config->refSat || refImage->data.F32[y][x] <= config->refBad || 60 isnan(refImage->data.F32[y][x])) { 61 mask->data.U8[y][x] |= POIS_MASK_BAD; 62 int xlow = MAX(0, x - config->xKernel); 63 int xhigh = MIN(nx, x + config->xKernel); 64 int ylow = MAX(0, y - config->yKernel); 65 int yhigh = MIN(ny, y + config->yKernel); 66 for (int v = ylow; v <= yhigh; v++) { 67 for (int u = xlow; u <= xhigh; u++) { 68 mask->data.U8[v][u] |= POIS_MASK_NEAR_BAD; 69 } 70 } 71 } else if (inImage->data.F32[y][x] >= config->inSat || inImage->data.F32[y][x] <= config->inBad || 72 isnan(inImage->data.F32[y][x])) { 73 mask->data.U8[y][x] |= POIS_MASK_BAD; 74 } 75 } 60 76 } 61 77 -
trunk/pois/src/poisMaskOps.c
r3806 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 /* 2 18 * Some utility routines that should be in psLib … … 8 24 #include "pois.h" 9 25 10 psImage *poisImageSetVal(psImage *restrict in, // Input image11 const psC64 val// set to this value26 psImage *poisImageSetVal(psImage *restrict in, // Input image 27 const psC64 val // set to this value 12 28 ) 13 29 { … … 16 32 switch (in->type.type) { 17 33 case PS_TYPE_U8: 18 {19 const int numCols = in->numCols;20 psU8 *row0 = in->data.U8[0];21 for (int c = 0; c < numCols; c++) {22 row0[c] = val;23 }24 for (int r = 1; r < in->numRows; r++) {25 memcpy(in->data.U8[r], row0, numCols*sizeof(psU8));26 }27 }28 break;34 { 35 const int numCols = in->numCols; 36 psU8 *row0 = in->data.U8[0]; 37 for (int c = 0; c < numCols; c++) { 38 row0[c] = val; 39 } 40 for (int r = 1; r < in->numRows; r++) { 41 memcpy(in->data.U8[r], row0, numCols*sizeof(psU8)); 42 } 43 } 44 break; 29 45 case PS_TYPE_F32: 30 {31 const int numCols = in->numCols;32 psF32 *row0 = in->data.F32[0];33 for (int c = 0; c < numCols; c++) {34 row0[c] = val;35 }36 for (int r = 1; r < in->numRows; r++) {37 memcpy(in->data.F32[r], row0, numCols*sizeof(psF32));38 }39 }40 break;46 { 47 const int numCols = in->numCols; 48 psF32 *row0 = in->data.F32[0]; 49 for (int c = 0; c < numCols; c++) { 50 row0[c] = val; 51 } 52 for (int r = 1; r < in->numRows; r++) { 53 memcpy(in->data.F32[r], row0, numCols*sizeof(psF32)); 54 } 55 } 56 break; 41 57 default: 42 psError(POIS_ERR_UNSUPPORTED_TYPE, true,43 "Type %d is not supported", in->type.type);44 return NULL;58 psError(POIS_ERR_UNSUPPORTED_TYPE, true, 59 "Type %d is not supported", in->type.type); 60 return NULL; 45 61 } 46 62 … … 48 64 } 49 65 50 psImage *poisImageSetValInMask(psImage *out, // Image to update, or NULL51 const psImage *restrict in,// Input image52 const psImage *mask,// mask for image53 const psC64 val,// set to this value54 const unsigned long bits// set pixels where mask & bits != 066 psImage *poisImageSetValInMask(psImage *out, // Image to update, or NULL 67 const psImage *restrict in, // Input image 68 const psImage *mask, // mask for image 69 const psC64 val, // set to this value 70 const unsigned long bits // set pixels where mask & bits != 0 55 71 ) 56 72 { … … 65 81 // Allocate the output image, if necessary 66 82 if (out == NULL) { 67 out = psImageCopy(NULL, in, in->type.type);83 out = psImageCopy(NULL, in, in->type.type); 68 84 } 69 85 70 86 switch (in->type.type) { 71 87 case PS_TYPE_F32: 72 {73 const int numCols = in->numCols;74 for (int r = 0; r < in->numRows; r++) {75 psF32 *row = out->data.F32[r]; // n.b. a copy of in76 psU8 *mrow = mask->data.U8[r];77 for (int c = 0; c < numCols; c++) {78 if (mrow[c] & bits) {79 row[c] = val;80 }81 }82 }83 }84 break;88 { 89 const int numCols = in->numCols; 90 for (int r = 0; r < in->numRows; r++) { 91 psF32 *row = out->data.F32[r]; // n.b. a copy of in 92 psU8 *mrow = mask->data.U8[r]; 93 for (int c = 0; c < numCols; c++) { 94 if (mrow[c] & bits) { 95 row[c] = val; 96 } 97 } 98 } 99 } 100 break; 85 101 default: 86 psError(POIS_ERR_UNSUPPORTED_TYPE, true,87 "Type %d is not supported", in->type.type);88 return NULL;102 psError(POIS_ERR_UNSUPPORTED_TYPE, true, 103 "Type %d is not supported", in->type.type); 104 return NULL; 89 105 } 90 106 -
trunk/pois/src/poisParseConfig.c
r5717 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <unistd.h> … … 7 23 { 8 24 fprintf (stderr, "POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction\n" 9 "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B1 B2] [-B BG] [-o N] [-n NSTAMPS] [-S STAMPS] [-i ITER] [-r REJ] [-m] REF IN OUT\n"10 "where\n"11 "\t-h Help (this info)\n"12 "\t-v Increase verbosity level\n"13 "\t-k X Y Kernel half-size in x and y (5)\n"14 "\t-t T Threshold for stamps on reference image (0)\n"15 "\t-s S1 S2 Saturation level for reference (S1) and input (S2) (50000)\n"16 "\t-b B1 B2 Bad level for both images (0)\n"17 "\t-B BG Level to add to background to get above zero (0)\n"18 "\t-o ORDER Order of spatial variations in the kernel (0)\n"19 "\t-n NSTAMPS Number of stamps in each dimension (5)\n"20 "\t-S STAMPS File from which to read stamps\n"21 "\t-R Reverse the sense of the subtraction (REF - IN)\n"22 "\t-i ITER Number of rejection iterations (10)\n"23 "\t-r REJ Rejection level in standard deviations (2.5)\n"24 "\t-m Output mask frame (OUT.mask)\n"25 "\tREF Reference image\n"26 "\tIN Input image (to be matched to REF)\n"27 "\tOUT Output image\n"28 );25 "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B1 B2] [-B BG] [-o N] [-n NSTAMPS] [-S STAMPS] [-i ITER] [-r REJ] [-m] REF IN OUT\n" 26 "where\n" 27 "\t-h Help (this info)\n" 28 "\t-v Increase verbosity level\n" 29 "\t-k X Y Kernel half-size in x and y (5)\n" 30 "\t-t T Threshold for stamps on reference image (0)\n" 31 "\t-s S1 S2 Saturation level for reference (S1) and input (S2) (50000)\n" 32 "\t-b B1 B2 Bad level for both images (0)\n" 33 "\t-B BG Level to add to background to get above zero (0)\n" 34 "\t-o ORDER Order of spatial variations in the kernel (0)\n" 35 "\t-n NSTAMPS Number of stamps in each dimension (5)\n" 36 "\t-S STAMPS File from which to read stamps\n" 37 "\t-R Reverse the sense of the subtraction (REF - IN)\n" 38 "\t-i ITER Number of rejection iterations (10)\n" 39 "\t-r REJ Rejection level in standard deviations (2.5)\n" 40 "\t-m Output mask frame (OUT.mask)\n" 41 "\tREF Reference image\n" 42 "\tIN Input image (to be matched to REF)\n" 43 "\tOUT Output image\n" 44 ); 29 45 } 30 46 31 47 poisConfig *poisParseConfig(int argc, // Number of command-line arguments 32 char **argv // Command-line arguments48 char **argv // Command-line arguments 33 49 ) 34 50 { 35 poisConfig *config; // Configuration values51 poisConfig *config; // Configuration values 36 52 37 53 /* Variables for getopt */ … … 68 84 while ((opt = getopt(argc, argv, "hvRmk:f:q:t:s:o:b:B:n:i:r:p:S:")) != -1) { 69 85 switch (opt) { 70 case 'h':71 help();72 exit(EXIT_SUCCESS);73 case 'v':86 case 'h': 87 help(); 88 exit(EXIT_SUCCESS); 89 case 'v': 74 90 config->verbose++; 75 91 break; 76 case 'k':92 case 'k': 77 93 if ((sscanf(argv[optind-1], "%d", &config->xKernel) != 1) || 78 94 (sscanf(argv[optind++], "%d", &config->yKernel) != 1)) { … … 84 100 exit(EXIT_FAILURE); 85 101 } 86 break;87 case 'f':88 if (sscanf(optarg, "%d", &config->footprint) != 1) {89 help();90 exit(EXIT_FAILURE); 91 }92 break;93 case 't':94 if (sscanf(optarg, "%f", &config->threshold) != 1) {95 help();96 exit(EXIT_FAILURE); 97 }98 break;99 case 's':102 break; 103 case 'f': 104 if (sscanf(optarg, "%d", &config->footprint) != 1) { 105 help(); 106 exit(EXIT_FAILURE); 107 } 108 break; 109 case 't': 110 if (sscanf(optarg, "%f", &config->threshold) != 1) { 111 help(); 112 exit(EXIT_FAILURE); 113 } 114 break; 115 case 's': 100 116 if ((sscanf(argv[optind-1], "%f", &config->refSat) != 1) || 101 117 (sscanf(argv[optind++], "%f", &config->inSat) != 1)) { … … 107 123 exit(EXIT_FAILURE); 108 124 } 109 break;110 case 'o':111 if (sscanf(optarg, "%d", &config->spatialOrder) != 1) {112 help();113 exit(EXIT_FAILURE); 114 }115 break;116 case 'b':125 break; 126 case 'o': 127 if (sscanf(optarg, "%d", &config->spatialOrder) != 1) { 128 help(); 129 exit(EXIT_FAILURE); 130 } 131 break; 132 case 'b': 117 133 if ((sscanf(argv[optind-1], "%f", &config->refBad) != 1) || 118 134 (sscanf(argv[optind++], "%f", &config->inBad) != 1)) { … … 124 140 exit(EXIT_FAILURE); 125 141 } 126 break;127 case 'B':128 if (sscanf(optarg, "%f", &config->background) != 1) {129 help();130 exit(EXIT_FAILURE); 131 }132 break;133 case 'n':142 break; 143 case 'B': 144 if (sscanf(optarg, "%f", &config->background) != 1) { 145 help(); 146 exit(EXIT_FAILURE); 147 } 148 break; 149 case 'n': 134 150 if (sscanf(argv[optind-1], "%d", &config->nsx) != 1) { 135 151 help(); 136 152 exit(EXIT_FAILURE); 137 153 } 138 config->nsy = config->nsx;139 break;140 case 'i':154 config->nsy = config->nsx; 155 break; 156 case 'i': 141 157 if (sscanf(argv[optind-1], "%d", &config->numIter) != 1) { 142 158 help(); 143 159 exit(EXIT_FAILURE); 144 160 } 145 break;146 case 'r':161 break; 162 case 'r': 147 163 if (sscanf(argv[optind-1], "%f", &config->sigmaRej) != 1) { 148 164 help(); 149 165 exit(EXIT_FAILURE); 150 166 } 151 break;152 case 'p':167 break; 168 case 'p': 153 169 if (sscanf(argv[optind-1], "%f", &config->penalty) != 1) { 154 170 help(); 155 171 exit(EXIT_FAILURE); 156 172 } 157 break;158 case 'S':159 config->stampFile = argv[optind-1];160 config->threshold = -INFINITY;161 break;162 case 'R':163 config->reverse = true;164 break;165 case 'm':173 break; 174 case 'S': 175 config->stampFile = argv[optind-1]; 176 config->threshold = -INFINITY; 177 break; 178 case 'R': 179 config->reverse = true; 180 break; 181 case 'm': 166 182 config->mask = true; 167 183 break; 168 default:169 help();170 }184 default: 185 help(); 186 } 171 187 } 172 188 -
trunk/pois/src/poisReadStamps.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include "pslib.h" -
trunk/pois/src/poisRejectStamps.c
r5717 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisSolveEquation.c
r6891 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include <assert.h> -
trunk/pois/src/poisStamp.c
r5717 r8480 1 // Copyright (C) 2006 Paul A. Price (price@ifa.hawaii.edu) 2 // 3 // This program is free software; you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation; either version 2 of the License, or 6 // (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, write to the Free Software 15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 1 17 #include <stdio.h> 2 18 #include "pslib.h" … … 19 35 { 20 36 if (stamp->matrix) { 21 psFree(stamp->matrix);37 psFree(stamp->matrix); 22 38 } 23 39 if (stamp->vector) { 24 psFree(stamp->vector);40 psFree(stamp->vector); 25 41 } 26 42 psFree(stamp); … … 30 46 // Return true if the stamp is OK 31 47 bool poisCheckStamp(const psImage *image, // Image to check for threshold 32 const psImage *mask, // Mask to check for bad pixels33 int x, int y,// Pixel coordinates34 const poisConfig *config // Configuration48 const psImage *mask, // Mask to check for bad pixels 49 int x, int y, // Pixel coordinates 50 const poisConfig *config // Configuration 35 51 ) 36 52 { 37 53 if (x < config->footprint + config->xKernel || 38 y < config->footprint + config->yKernel ||39 x > config->xImage - config->footprint - config->xKernel ||40 y > config->yImage - config->footprint - config->yKernel ||41 image->data.F32[y][x] < config->threshold) {42 psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (border/threshold)\n", x, y);43 return false;54 y < config->footprint + config->yKernel || 55 x > config->xImage - config->footprint - config->xKernel || 56 y > config->yImage - config->footprint - config->yKernel || 57 image->data.F32[y][x] < config->threshold) { 58 psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (border/threshold)\n", x, y); 59 return false; 44 60 } 45 61 46 62 // Check the footprint 47 bool ok = true; // Is the footprint OK?48 int footprint = config->footprint; // Footprint size63 bool ok = true; // Is the footprint OK? 64 int footprint = config->footprint; // Footprint size 49 65 for (int v = y - footprint; v <= y + footprint && ok; v++) { 50 for (int u = x - footprint; u <= x + footprint && ok; u++) {51 if (mask->data.U8[v][u] &52 (POIS_MASK_BAD | POIS_MASK_NEAR_BAD | POIS_MASK_STAMP)) {53 psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (bad footprint)\n", x, y);54 ok = false;55 }56 }66 for (int u = x - footprint; u <= x + footprint && ok; u++) { 67 if (mask->data.U8[v][u] & 68 (POIS_MASK_BAD | POIS_MASK_NEAR_BAD | POIS_MASK_STAMP)) { 69 psTrace("pois.checkStamp", 9, "Rejecting stamp at %d,%d (bad footprint)\n", x, y); 70 ok = false; 71 } 72 } 57 73 } 58 74 59 75 return ok; 60 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
