IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 22, 2006, 2:48:04 PM (20 years ago)
Author:
Paul Price
Message:

Adding GPL stuff, for distribution

File:
1 edited

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
    117#include <stdio.h>
    218#include <assert.h>
     
    723#define MIN(a,b) ((a) < (b) ? (a) : (b))
    824
    9 psImage *poisMakeMask(psImage *mask,    // Mask to update, or NULL
    10                       const psImage *refImage, // Reference image
    11                       const psImage *inImage, // Input image
    12                       const poisConfig *config // Configuration
     25psImage *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
    1329    )
    1430{
     
    2036    assert(config);
    2137
    22     int nx = config->xImage;            // Size in x
    23     int ny = config->yImage;            // Size in y
     38    int nx = config->xImage;            // Size in x
     39    int ny = config->yImage;            // Size in y
    2440
    2541    psTrace("pois.makeMask", 5, "Creating mask: %dx%d\n", nx, ny);
     
    2743    // Allocate the mask image, if necessary
    2844    if (mask == NULL) {
    29         mask = psImageAlloc(nx, ny, PS_TYPE_U8);
    30         // Initialise to zero
    31         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        }
    3652    }
    3753
    3854    // Iterate over the images
    3955    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 convolved
    42             // But only mask single pixel in the input image, since it doesn't get convolved
    43             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        }
    6076    }
    6177
Note: See TracChangeset for help on using the changeset viewer.