IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26472


Ignore:
Timestamp:
Dec 22, 2009, 9:54:34 AM (16 years ago)
Author:
eugene
Message:

adding more visualizations

Location:
branches/eam_branches/20091201/psModules/src/imcombine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.c

    r26429 r26472  
    216216    pmVisualScaleImage(kapa1, ref, "Reference", 1, true);
    217217    pmVisualScaleImage(kapa1, sub, "Subtraction", 2, true);
     218    pmVisualAskUser(&plotImage);
     219    return true;
     220}
     221
     222bool pmSubtractionVisualShowKernels(pmSubtractionKernels *kernels) {
     223
     224    if (!pmVisualIsVisual()) return true;
     225    if (!pmVisualInitWindow (&kapa1, "PPSub:Images")) {
     226        return false;
     227    }
     228
     229    // get the kernel sizes
     230    int footprint = kernels->size;
     231
     232    // output image is a grid of NXsub by NYsub sub-images
     233    int NXsub = sqrt(kernels->num);
     234    int NYsub = kernels->num / NXsub;
     235    if (kernels->num % NXsub) NYsub++;
     236
     237    int NXpix = NXsub * (2*footprint + 1 + 3);
     238    int NYpix = NYsub * (2*footprint + 1 + 3);
     239
     240    psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32);
     241    psImageInit (output, 0.0);
     242
     243    for (int i = 0; i < kernels->num; i++) {
     244        psArray *preCalc = kernels->preCalc->data[i];
     245        psKernel *kernel = preCalc->data[2];
     246
     247        int xSub = i % NXsub;
     248        int ySub = i / NXsub;
     249
     250        int xPix = xSub * (2*footprint + 1 + 3) + footprint;
     251        int yPix = ySub * (2*footprint + 1 + 3) + footprint;
     252
     253        for (int y = -footprint; y <= footprint; y++) {
     254            for (int x = -footprint; x <= footprint; x++) {
     255                output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x];
     256            }
     257        }
     258    }                                                   
     259       
     260    pmVisualScaleImage(kapa1, output, "Image", 0, true);
     261    pmVisualAskUser(&plotImage);
     262    return true;
     263}
     264
     265bool pmSubtractionVisualShowBasis(pmSubtractionStampList *stamps) {
     266
     267    if (!pmVisualIsVisual()) return true;
     268    if (!pmVisualInitWindow (&kapa2, "ppSub:StampMasterImage")) {
     269        return false;
     270    }
     271
     272    // get the kernel sizes
     273    int footprint = stamps->footprint;
     274
     275    // choose the brightest stamp
     276    pmSubtractionStamp *maxStamp = stamps->stamps->data[0];
     277    float maxFlux = maxStamp->flux;
     278    for (int i = 1; i < stamps->num; i++) {
     279        pmSubtractionStamp *stamp = stamps->stamps->data[i];
     280        if (stamp->flux > maxFlux) {
     281            maxFlux = stamp->flux;
     282            maxStamp = stamp;
     283        }
     284    }
     285
     286    int nKernels = 0;
     287
     288    if (maxStamp->convolutions1) {
     289        // output image is a grid of NXsub by NYsub sub-images
     290        nKernels = maxStamp->convolutions1->n;
     291        int NXsub = sqrt(nKernels);
     292        int NYsub = nKernels / NXsub;
     293        if (nKernels % NXsub) NYsub++;
     294
     295        int NXpix = NXsub * (2*footprint + 1 + 3);
     296        int NYpix = NYsub * (2*footprint + 1 + 3);
     297
     298        psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32);
     299        psImageInit (output, 0.0);
     300
     301        for (int i = 0; i < nKernels; i++) {
     302            psKernel *kernel = maxStamp->convolutions1->data[i];
     303           
     304            int xSub = i % NXsub;
     305            int ySub = i / NXsub;
     306           
     307            int xPix = xSub * (2*footprint + 1 + 3) + footprint;
     308            int yPix = ySub * (2*footprint + 1 + 3) + footprint;
     309           
     310            for (int y = -footprint; y <= footprint; y++) {
     311                for (int x = -footprint; x <= footprint; x++) {
     312                    output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x];
     313                }
     314            }
     315        }               
     316        pmVisualScaleImage(kapa2, output, "Image", 0, true);
     317    }                                   
     318       
     319    if (maxStamp->convolutions2) {
     320        // output image is a grid of NXsub by NYsub sub-images
     321        nKernels = maxStamp->convolutions2->n;
     322        int NXsub = sqrt(nKernels);
     323        int NYsub = nKernels / NXsub;
     324        if (nKernels % NXsub) NYsub++;
     325
     326        int NXpix = NXsub * (2*footprint + 1 + 3);
     327        int NYpix = NYsub * (2*footprint + 1 + 3);
     328
     329        psImage *output = psImageAlloc(NXpix, NYpix, PS_TYPE_F32);
     330        psImageInit (output, 0.0);
     331
     332        for (int i = 0; i < nKernels; i++) {
     333            psKernel *kernel = maxStamp->convolutions2->data[i];
     334           
     335            int xSub = i % NXsub;
     336            int ySub = i / NXsub;
     337           
     338            int xPix = xSub * (2*footprint + 1 + 3) + footprint;
     339            int yPix = ySub * (2*footprint + 1 + 3) + footprint;
     340           
     341            for (int y = -footprint; y <= footprint; y++) {
     342                for (int x = -footprint; x <= footprint; x++) {
     343                    output->data.F32[y + yPix][x + xPix] = kernel->kernel[y][x];
     344                }
     345            }
     346        }               
     347        pmVisualScaleImage(kapa2, output, "Image", 1, true);
     348    }                                   
     349       
    218350    pmVisualAskUser(&plotImage);
    219351    return true;
  • branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.h

    r26318 r26472  
    1111bool pmSubtractionVisualShowFit();
    1212bool pmSubtractionVisualPlotFit(const pmSubtractionKernels *kernels);
     13bool pmSubtractionVisualShowKernels(pmSubtractionKernels *kernels);
     14bool pmSubtractionVisualShowBasis(pmSubtractionStampList *stamps);
    1315
    1416#endif
Note: See TracChangeset for help on using the changeset viewer.