IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16403


Ignore:
Timestamp:
Feb 11, 2008, 6:04:21 PM (18 years ago)
Author:
Paul Price
Message:

Fixing to use modern APIs for pmSubtractionKernels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmStackReject.c

    r15756 r16403  
    1111#define PIXEL_LIST_BUFFER 100           // Number of pixels to add to list at a time
    1212
    13 psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions,
    14                         const psArray *solutions, const pmSubtractionKernels *kernels)
     13psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions, const psArray *kernels)
    1514{
    1615    PS_ASSERT_PIXELS_NON_NULL(in, NULL);
     
    1817    PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(threshold, 1.0, NULL);
    1918    PS_ASSERT_ARRAY_NON_NULL(regions, NULL);
    20     PS_ASSERT_ARRAY_NON_NULL(solutions, NULL);
    21     PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, solutions, NULL);
    22     PS_ASSERT_PTR_NON_NULL(kernels, NULL);
     19    PS_ASSERT_ARRAY_NON_NULL(kernels, NULL);
     20    PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, kernels, NULL);
    2321
    2422    // Get the original image size
     
    2624    int numCols = 0, numRows = 0;       // Size of original image
    2725    int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image --- should be 0,0
     26    int size = 0;                       // Size of kernel
    2827    for (int i = 0; i < numRegions; i++) {
    2928        psRegion *region = regions->data[i]; // Region of interest
     
    3938        if (region->y1 > numRows) {
    4039            numRows = region->y1;
     40        }
     41
     42        pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest
     43        if (size == 0) {
     44            size = kernel->size;
     45        } else if (kernel->size != size) {
     46            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Kernel sizes are not identical: %d vs %d",
     47                    size, kernel->size);
     48            return NULL;
    4149        }
    4250    }
     
    5765    for (int i = 0; i < numRegions; i++) {
    5866        psRegion *region = regions->data[i]; // Region of interest
    59         if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernels, true)) {
     67        pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest
     68        if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) {
    6069            psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);
    6170            psFree(convRO);
     
    7079        float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - numCols/2.0) / (float)numCols;
    7180        float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - numRows/2.0) / (float)numRows;
    72         psImage *kernel = pmSubtractionKernelImage(kernels, xNorm, yNorm, false);
    73         if (!kernel) {
     81        psImage *image = pmSubtractionKernelImage(kernel, xNorm, yNorm, false);
     82        if (!image) {
    7483            psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");
    7584            psFree(convRO);
     
    7887        }
    7988        float sum = 0.0;
    80         for (int y = 0; y < kernel->numRows; y++) {
    81             for (int x = 0; x < kernel->numCols; x++) {
    82                 sum += kernel->data.F32[y][x];
     89        for (int y = 0; y < image->numRows; y++) {
     90            for (int x = 0; x < image->numCols; x++) {
     91                sum += image->data.F32[y][x];
    8392            }
    8493        }
    85         psFree(kernel);
     94        psFree(image);
    8695
    8796        psImage *subConv = psImageSubset(convRO->image, *region); // Sub-image of convolved image
     
    103112    psFree(convolved);
    104113
    105     // Now, we want to convolve the original pixels properly
     114    // Now, grow the mask to include everything that touches a bad pixel in the convolution
    106115    mask = psPixelsToMask(NULL, bad, psRegionSet(0, numCols, 0, numRows), 0xff);
    107     int size = kernels->size;           // Size of kernels
    108116    for (int i = 0; i < bad->n; i++) {
    109117        int xPix = bad->data[i].x, yPix = bad->data[i].y; // Coordinates of interest
Note: See TracChangeset for help on using the changeset viewer.