IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2009, 7:10:07 PM (17 years ago)
Author:
Paul Price
Message:

Being more careful with the normalisation. Decided that we normalise
everything to match the input image --- so if we convolve the input
image, then we need to fix the normalisation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r24257 r24334  
    2121
    2222#include "ppSub.h"
     23
     24// Normalise a region on an image
     25static void normaliseRegion(psImage *image, // Image to normalise
     26                            const psRegion *region, // Region of image to normalise
     27                            float norm  // Normalisation
     28                            )
     29{
     30    if (!image) {
     31        return;
     32    }
     33    psAssert(region, "Expect region");
     34    psImage *subImage = psImageSubset(image, *region); // Sub-image
     35    psBinaryOp(subImage, subImage, "*", psScalarAlloc(norm, PS_TYPE_F32));
     36    psFree(subImage);
     37    return;
     38}
     39
    2340
    2441bool ppSubMatchPSFs(ppSubData *data)
     
    177194    }
    178195
     196    // Need to be careful with the normalisation
     197    // We will normalise everything to the normalisation of the *input* image
     198    {
     199        // Since the entries are MULTI, we have to retrieve them differently
     200        psMetadataIterator *regIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD,
     201                                                              "^" PM_SUBTRACTION_ANALYSIS_REGION "$");
     202        psMetadataIterator *modeIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD,
     203                                                              "^" PM_SUBTRACTION_ANALYSIS_MODE "$");
     204        psMetadataIterator *normIter = psMetadataIteratorAlloc(inConv->analysis, PS_LIST_HEAD,
     205                                                              "^" PM_SUBTRACTION_ANALYSIS_NORM "$");
     206        psMetadataItem *regItem;        // Item with region
     207        while ((regItem = psMetadataGetAndIncrement(regIter))) {
     208            psAssert(regItem->type == PS_DATA_REGION && regItem->data.V, "Expect region type");
     209            psRegion *region = regItem->data.V; // Region of interest
     210            psMetadataItem *modeItem = psMetadataGetAndIncrement(modeIter); // Item with mode
     211            psAssert(modeItem && modeItem->type == PS_TYPE_S32, "Expect subtraction mode");
     212            pmSubtractionMode mode = modeItem->data.S32; // Subtraction mode
     213            psMetadataItem *normItem = psMetadataGetAndIncrement(normIter); // Item with normalisation
     214            psAssert(normItem && normItem->type == PS_TYPE_F32 && isfinite(normItem->data.F32),
     215                     "Expect normalisation");
     216            float norm = normItem->data.F32; // Normalisation
     217
     218            switch (mode) {
     219              case PM_SUBTRACTION_MODE_1: // Convolved the input to match template
     220              case PM_SUBTRACTION_MODE_DUAL: // Convolved both; template should have flux conserved
     221                psLogMsg("ppSub", PS_LOG_INFO, "Correcting image for normalisation of %f\n", norm);
     222                normaliseRegion(inConv->image, region, 1.0 / norm);
     223                normaliseRegion(refConv->image, region, 1.0 / norm);
     224                normaliseRegion(inConv->variance, region, 1.0 / PS_SQR(norm));
     225                normaliseRegion(refConv->variance, region, 1.0 / PS_SQR(norm));
     226                break;
     227              case PM_SUBTRACTION_MODE_2:       // Convolved the template to match input
     228                // We're already happy!
     229                psLogMsg("ppSub", PS_LOG_INFO, "Image normalisation is correct\n");
     230                break;
     231              default:
     232                psAbort("Invalid subtraction mode: %x", mode);
     233            }
     234        }
     235        psFree(regIter);
     236        psFree(modeIter);
     237        psFree(normIter);
     238    }
     239
     240
    179241    pmConceptsCopyFPA(inConv->parent->parent->parent, inRO->parent->parent->parent, true, true);
    180242    pmConceptsCopyFPA(refConv->parent->parent->parent, refRO->parent->parent->parent, true, true);
Note: See TracChangeset for help on using the changeset viewer.