Changeset 8480 for trunk/pois/src/poisMakeMask.c
- Timestamp:
- Aug 22, 2006, 2:48:04 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/pois/src/poisMakeMask.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
