IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28346


Ignore:
Timestamp:
Jun 15, 2010, 4:26:53 PM (16 years ago)
Author:
Paul Price
Message:

Allow application of a constant instead of an image.

Location:
trunk/ppArith/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppArith/src/ppArith.h

    r23195 r28346  
    4444                    const pmReadout *input1, ///< Input readout
    4545                    const pmReadout *input2, ///< Input readout
     46                    float const2,            ///< Constant to apply
    4647                    const pmConfig *config, ///< Configuration
    4748                    const pmFPAview *view ///< View of readout on which to operate
  • trunk/ppArith/src/ppArithArguments.c

    r21378 r28346  
    5151                        )
    5252{
    53     psString value = psMetadataLookupStr(NULL, arguments, argName); // Value of interest 
     53    psString value = psMetadataLookupStr(NULL, arguments, argName); // Value of interest
    5454    if (value && strlen(value) > 0) {
    5555        return psMetadataAddStr(target, PS_LIST_TAIL, mdName, 0, NULL, value);
     
    8282    psMetadataAddStr(arguments, PS_LIST_TAIL, "-op", 0, "Operation to perform", NULL);
    8383    psMetadataAddStr(arguments, PS_LIST_TAIL, "-file2", 0, "Second image", NULL);
     84    psMetadataAddF32(arguments, PS_LIST_TAIL, "-const2", 0, "Constant", NAN);
    8485    psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask", 0, "Treat images as masks", false);
    8586    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
     
    9899                     "File rule for output", outFilerule);
    99100
    100     bool status = false;                // Status for file definition 
     101    bool status = false;                // Status for file definition
    101102
    102103    // First file
     
    135136        }
    136137    }
     138    float const2 = psMetadataLookupF32(NULL, arguments, "-const2"); // Constant to apply
     139    if (!isnan(const2)) {
     140        if (name2) {
     141            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Cannot specify both -file2 and -const2");
     142            goto ERROR;
     143        }
     144        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "PPARITH.CONST", 0, "Constant to apply", const2);
     145    }
    137146
    138147    // Output image
  • trunk/ppArith/src/ppArithLoop.c

    r26903 r28346  
    6262    }
    6363    psFree(iter);
     64
     65    float const2 = psMetadataLookupF32(&mdok, config->arguments, "PPARITH.CONST");
    6466
    6567    pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy
     
    138140
    139141                // Perform the analysis
    140                 if (!ppArithReadout(outRO, inRO1, inRO2, config, view)) {
     142                if (!ppArithReadout(outRO, inRO1, inRO2, const2, config, view)) {
    141143                    psError(PS_ERR_UNKNOWN, false, "Unable to perform arithmetic.\n");
    142144                    return false;
  • trunk/ppArith/src/ppArithReadout.c

    r21378 r28346  
    2121#include "ppArith.h"
    2222
    23 bool ppArithReadout(pmReadout *output, const pmReadout *input1, const pmReadout *input2,
     23bool ppArithReadout(pmReadout *output, const pmReadout *input1, const pmReadout *input2, float const2,
    2424                    const pmConfig *config, const pmFPAview *view)
    2525{
     
    7777    if (input2) {
    7878        psBinaryOp(outImage, inImage1, op, inImage2);
     79    }  else if (!isnan(const2)) {
     80        psBinaryOp(outImage, inImage1, op, psScalarAlloc(const2, inImage1->type.type));
    7981    } else {
    8082        psUnaryOp(outImage, inImage1, op);
Note: See TracChangeset for help on using the changeset viewer.