IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14524


Ignore:
Timestamp:
Aug 15, 2007, 4:57:34 PM (19 years ago)
Author:
Paul Price
Message:

Don't need to give pmSubtractionRejectStamps the images, since those are contained in the stamps now.

Location:
trunk/psModules/src/imcombine
Files:
2 edited

Legend:

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

    r14515 r14524  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-08-16 00:32:43 $
     6 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-08-16 02:57:34 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    644644
    645645
    646 int pmSubtractionRejectStamps(psArray *stamps, const psImage *refImage, psImage *inImage,
    647                               psImage *subMask, const psVector *solution, int footprint, float sigmaRej,
    648                               const pmSubtractionKernels *kernels)
     646int pmSubtractionRejectStamps(psArray *stamps, psImage *subMask, const psVector *solution,
     647                              int footprint, float sigmaRej, const pmSubtractionKernels *kernels)
    649648{
    650649    PS_ASSERT_ARRAY_NON_NULL(stamps, -1);
    651     PS_ASSERT_IMAGE_NON_EMPTY(refImage, -1);
    652     PS_ASSERT_IMAGE_TYPE(refImage, PS_TYPE_F32, -1);
    653     PS_ASSERT_IMAGE_NON_EMPTY(inImage, -1);
    654     PS_ASSERT_IMAGE_TYPE(inImage, PS_TYPE_F32, -1);
    655     PS_ASSERT_IMAGES_SIZE_EQUAL(refImage, inImage, -1);
    656650    PS_ASSERT_IMAGE_NON_EMPTY(subMask, -1);
    657651    PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, -1);
    658     PS_ASSERT_IMAGES_SIZE_EQUAL(refImage, subMask, -1);
    659652    PS_ASSERT_VECTOR_NON_NULL(solution, -1);
    660653    PS_ASSERT_VECTOR_TYPE(solution, PS_TYPE_F64, -1);
     
    670663    int numStamps = 0;                  // Number of used stamps
    671664    {
    672         int numCols = refImage->numCols, numRows = refImage->numRows; // Image dimensions
    673665        psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // Statistics
    674         psImage *convolvedStamp = psImageAlloc(2 * footprint + 1, 2 * footprint + 1,
    675                                                PS_TYPE_F32); // Convolved image of stamp
     666        psKernel *convolution = psKernelAlloc(-footprint, footprint, -footprint, footprint); // Convolution
    676667        psKernel *kernelImage = NULL;       // The kernel, with which to convolve the stamps
    677668        float background = solution->data.F64[solution->n-1]; // The difference in background
     
    683674                continue;
    684675            }
    685             int xStamp = stamp->x, yStamp = stamp->y; // Coordinates of stamp
    686 
    687             float xNorm = 2.0 * (float)(stamp->x - numCols/2.0) / (float)numCols; // Normalised x coord
    688             float yNorm = 2.0 * (float)(stamp->y - numRows/2.0) / (float)numRows; // Normalised y coord
    689             psImage *polyValues = spatialPolyValues(kernels->spatialOrder, xNorm, yNorm); // Polynomial terms
     676
     677            psImage *polyValues = spatialPolyValues(kernels->spatialOrder, stamp->xNorm,
     678                                                    stamp->yNorm); // Polynomial terms
     679
     680            psKernel *reference = stamp->reference; // Reference postage stamp
    690681
    691682            kernelImage = solvedKernel(kernelImage, solution, kernels, polyValues, false);
    692             for (int y = yStamp - footprint, j = 0; y <= yStamp + footprint; y++, j++) {
    693                 for (int x = xStamp - footprint, i = 0; x <= xStamp + footprint; x++, i++) {
    694                     convolvedStamp->data.F32[j][i] = background;
     683            for (int y = - footprint; y <= footprint; y++) {
     684                for (int x = - footprint; x <= footprint; x++) {
     685                    convolution->kernel[y][x] = background;
    695686                    for (int v = -size; v <= size; v++) {
    696687                        for (int u = -size; u <= size; u++) {
    697                             convolvedStamp->data.F32[j][i] += kernelImage->kernel[v][u] *
    698                                 refImage->data.F32[y + v][x + u];
     688                            convolution->kernel[y][x] += kernelImage->kernel[v][u] *
     689                                reference->kernel[y + v][x + u];
    699690                        }
    700691                    }
    701692                }
    702693            }
    703 
    704694            psFree(polyValues);
    705695
    706             psRegion region = psRegionSet(xStamp - footprint, xStamp + footprint + 1,
    707                                           yStamp - footprint, yStamp + footprint + 1); // Region of interest
    708             psImage *inStamp = psImageSubset(inImage, region); // Image of stamp
    709             assert(inStamp->numCols == convolvedStamp->numCols &&
    710                    inStamp->numRows == convolvedStamp->numRows);
     696            psImage *convolvedStamp = convolution->image; // Image of the convolution
     697            psImage *input = stamp->input->image; // Input image postage stamp
     698
     699            // Region of interest
     700            psRegion region = psRegionSet(input->col0 + size, input->col0 + size + 2 * footprint + 1,
     701                                          input->row0 + size, input->row0 + size + 2 * footprint + 1);
     702
     703            psImage *inStamp = psImageSubset(stamp->input->image, region); // Image of stamp
     704            assert(convolvedStamp->numCols == inStamp->numCols &&
     705                   convolvedStamp->numRows == inStamp->numRows);
    711706            (void)psBinaryOp(convolvedStamp, inStamp, "-", convolvedStamp);
    712707            (void)psBinaryOp(convolvedStamp, convolvedStamp, "*", convolvedStamp);
     
    717712                        "Unable to calculate statistics on normalised residual image of stamp.");
    718713                psFree(deviations);
    719                 psFree(convolvedStamp);
     714                psFree(convolution);
    720715                psFree(stats);
    721716                return -1;
     
    729724
    730725        psFree(kernelImage);
    731         psFree(convolvedStamp);
     726        psFree(convolution);
    732727        psFree(stats);
    733728    }
  • trunk/psModules/src/imcombine/pmSubtraction.h

    r14515 r14524  
    66 * @author GLG, MHPCC
    77 *
    8  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-08-16 00:32:43 $
     8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-08-16 02:57:34 $
    1010 * Copyright 2004-207 Institute for Astronomy, University of Hawaii
    1111 */
     
    5151/// Reject stamps
    5252int pmSubtractionRejectStamps(psArray *stamps, ///< Array of stamps to check for rejection
    53                               const psImage *refImage, ///< Reference image
    54                               psImage *inImage, ///< Input image
    5553                              psImage *subMask, ///< Subtraction mask
    5654                              const psVector *solution, ///< Solution vector
Note: See TracChangeset for help on using the changeset viewer.