Changeset 12954
- Timestamp:
- Apr 22, 2007, 12:23:20 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_02_branch/psModules/src/objects/pmSource.c
r12943 r12954 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.25.4. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 1 00:03:31$8 * @version $Revision: 1.25.4.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-22 22:23:20 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 733 733 return NULL; 734 734 } 735 736 // construct a realization of the source model 737 bool pmSourceCacheModel (pmSource *source) { 738 739 // select appropriate model 740 pmModel *model = pmSourceGetModel (NULL, source); 741 if (model == NULL) continue; // model must be defined 742 743 // if we already have a cached image, re-use that memory 744 if (source->modelFlux) { 745 psImageRecycle (source->modelFlux); 746 } else { 747 source->modelFlux = psImageCopy (source->pixels); 748 } 749 psImageInit (source->modelFlux, 0.0); 750 751 // in some places (psphotEnsemble), we need a normalized version 752 // in others, we just want the model. which is more commonly used? 753 pmModelAdd (source->modelFlux, source->mask, model, PM_MODEL_ADD_FULL | PM_MODEL_ADD_NORM); 754 return true; 755 } 756 757 // XXX should this API take an operator (+/-)? 758 // XXX should we specify norm, etc? 759 bool pmSourceAdd (pmSource *source) { 760 761 if (source->modelFlux) { 762 // add in the pixels from the modelFlux image 763 psImageSubsetAdd (source->pixels, source->modelFlux); 764 } else { 765 pmModel *model = pmSourceGetModel (NULL, source); 766 if (model == NULL) continue; // model must be defined 767 pmModelAdd (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 768 } 769 770 // we would need to save X,Y somehow (or use the peak?) 771 // psTrace ("psphot", 3, "replacing object at %f,%f\n", 772 // model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 773 return true; 774 } 775 776 bool pmSourceSub (pmSource *source) { 777 778 if (source->modelFlux) { 779 // add in the pixels from the modelFlux image 780 psImageSubsetSub (source->pixels, source->modelFlux); 781 } else { 782 pmModel *model = pmSourceGetModel (NULL, source); 783 if (model == NULL) continue; // model must be defined 784 pmModelSub (source->pixels, source->mask, model, PM_MODEL_ADD_FULL); 785 } 786 return true; 787 } 788 789 // XXX merge this function with psImageOverlay, which is probably mid-defined 790 bool psImageSubsetAdd (psImage *input, psImage *subset) { 791 792 // col0,row0 in both images refer to parent coordinates 793 794 int dX = subset->col0 - input->col0; 795 int dY = subset->row0 - input->row0; 796 assert (dX >= 0); 797 assert (dY >= 0); 798 assert (dX + subset->numCols < input->numCols); 799 assert (dY + subset->numRows < input->numRows); 800 assert (input->type.type == PS_TYPE_F32); 801 assert (subset->type.type == PS_TYPE_F32); 802 803 for (int iy = 0; iy < subset->numRows; iy++) { 804 oy = iy + dY; 805 for (int ix = 0; ix < subset->numCols; ix++) { 806 ox = ix + dX; 807 input->data.F32[oy][ox] += subset->data.F32[iy][ix]; 808 } 809 } 810 return true; 811 } 812 813 // XXX merge this function with psImageOverlay, which is probably mid-defined 814 bool psImageSubsetSub (psImage *input, psImage *subset) { 815 816 // col0,row0 in both images refer to parent coordinates 817 818 int dX = subset->col0 - input->col0; 819 int dY = subset->row0 - input->row0; 820 assert (dX >= 0); 821 assert (dY >= 0); 822 assert (dX + subset->numCols < input->numCols); 823 assert (dY + subset->numRows < input->numRows); 824 assert (input->type.type == PS_TYPE_F32); 825 assert (subset->type.type == PS_TYPE_F32); 826 827 for (int iy = 0; iy < subset->numRows; iy++) { 828 oy = iy + dY; 829 for (int ix = 0; ix < subset->numCols; ix++) { 830 ox = ix + dX; 831 input->data.F32[oy][ox] -= subset->data.F32[iy][ix]; 832 } 833 } 834 return true; 835 }
Note:
See TracChangeset
for help on using the changeset viewer.
