Changeset 13898 for trunk/psModules/src/objects/pmSource.c
- Timestamp:
- Jun 19, 2007, 4:22:26 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSource.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.c
r13338 r13898 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 5-10 20:25:05$8 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-20 02:22:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 135 135 *source->moments = *in->moments; 136 136 137 // These images are all views to the parent. 137 // These images are all views to the parent. 138 138 // We want a new view, but pointing at the same pixels. 139 139 source->pixels = psImageCopyView (NULL, in->pixels); … … 143 143 // the maskObj is a unique mask array; create a new mask image 144 144 if (in->maskObj) { 145 source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK);145 source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK); 146 146 } 147 147 … … 216 216 mySource->region = newRegion; 217 217 218 // re-copy the main mask pixels. NOTE: the user will need to reset the object mask219 // pixels (eg, with psImageKeepCircle)220 mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK);221 222 // drop the old modelFlux pixels and force the user to re-create223 psFree (mySource->modelFlux);224 mySource->modelFlux = NULL;218 // re-copy the main mask pixels. NOTE: the user will need to reset the object mask 219 // pixels (eg, with psImageKeepCircle) 220 mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK); 221 222 // drop the old modelFlux pixels and force the user to re-create 223 psFree (mySource->modelFlux); 224 mySource->modelFlux = NULL; 225 225 } 226 226 return extend; … … 233 233 234 234 // XXX EAM include a S/N cutoff in selecting the sources? 235 // XXX this function should probably accept the values, not a recipe. wrap with a 235 // XXX this function should probably accept the values, not a recipe. wrap with a 236 236 // psphot-specific function which applies the recipe values 237 237 pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata *recipe) … … 436 436 *****************************************************************************/ 437 437 438 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump )438 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump, psMaskType maskSat) 439 439 { 440 440 psTrace("psModules.objects", 5, "---- begin ----"); … … 487 487 inner = psRegionForSquare (source->peak->x, source->peak->y, 2); 488 488 inner = psRegionForImage (source->maskView, inner); 489 int Nsatpix = psImageCountPixelMask (source->maskView, inner, PM_MASK_SAT);489 int Nsatpix = psImageCountPixelMask (source->maskView, inner, maskSat); 490 490 491 491 // saturated star (size consistent with PSF or larger) … … 747 747 } 748 748 749 // construct a realization of the source model 750 bool pmSourceCacheModel (pmSource *source ) {749 // construct a realization of the source model 750 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal) { 751 751 752 752 // select appropriate model 753 753 pmModel *model = pmSourceGetModel (NULL, source); 754 754 if (model == NULL) return false; // model must be defined 755 755 756 756 // if we already have a cached image, re-use that memory 757 757 source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32); … … 761 761 // in others, we just want the model. which is more commonly used? 762 762 // modelFlux always has unity normalization (I0 = 1.0) 763 pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM );763 pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 764 764 return true; 765 765 } 766 766 767 767 // should we call pmSourceCacheModel if it does not exist? 768 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add ) {768 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal) { 769 769 770 770 bool status; 771 771 772 772 if (add) { 773 psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf);773 psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf); 774 774 } else { 775 psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf);775 psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf); 776 776 } 777 777 … … 780 780 781 781 if (source->modelFlux) { 782 // add in the pixels from the modelFlux image783 int dX = source->modelFlux->col0 - source->pixels->col0;784 int dY = source->modelFlux->row0 - source->pixels->row0;785 assert (dX >= 0);786 assert (dY >= 0);787 assert (dX + source->modelFlux->numCols <= source->pixels->numCols);788 assert (dY + source->modelFlux->numRows <= source->pixels->numRows);789 790 // modelFlux has unity normalization791 float Io = model->params->data.F32[PM_PAR_I0];792 if (mode & PM_MODEL_OP_NORM) {793 Io = 1.0;794 }795 796 psU8 **mask = NULL;797 if (source->maskObj) {798 mask = source->maskObj->data.U8;799 }800 801 psF32 **target = source->pixels->data.F32;802 if (mode & PM_MODEL_OP_NOISE) {803 target = source->weight->data.F32;804 }805 806 // XXX need to respect the source and model masks?807 for (int iy = 0; iy < source->modelFlux->numRows; iy++) {808 int oy = iy + dY;809 for (int ix = 0; ix < source->modelFlux->numCols; ix++) {810 int ox = ix + dX;811 if (mask && mask[iy][ix]) continue;812 float value = Io*source->modelFlux->data.F32[iy][ix];813 if (add) {814 target[oy][ox] += value;815 } else {816 target[oy][ox] -= value;817 }818 }819 }820 return true;821 } 782 // add in the pixels from the modelFlux image 783 int dX = source->modelFlux->col0 - source->pixels->col0; 784 int dY = source->modelFlux->row0 - source->pixels->row0; 785 assert (dX >= 0); 786 assert (dY >= 0); 787 assert (dX + source->modelFlux->numCols <= source->pixels->numCols); 788 assert (dY + source->modelFlux->numRows <= source->pixels->numRows); 789 790 // modelFlux has unity normalization 791 float Io = model->params->data.F32[PM_PAR_I0]; 792 if (mode & PM_MODEL_OP_NORM) { 793 Io = 1.0; 794 } 795 796 psU8 **mask = NULL; 797 if (source->maskObj) { 798 mask = source->maskObj->data.U8; 799 } 800 801 psF32 **target = source->pixels->data.F32; 802 if (mode & PM_MODEL_OP_NOISE) { 803 target = source->weight->data.F32; 804 } 805 806 // XXX need to respect the source and model masks? 807 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 808 int oy = iy + dY; 809 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 810 int ox = ix + dX; 811 if (mask && (mask[iy][ix] & maskVal)) continue; 812 float value = Io*source->modelFlux->data.F32[iy][ix]; 813 if (add) { 814 target[oy][ox] += value; 815 } else { 816 target[oy][ox] -= value; 817 } 818 } 819 } 820 return true; 821 } 822 822 823 823 psImage *target = source->pixels; 824 824 if (mode & PM_MODEL_OP_NOISE) { 825 target = source->weight;825 target = source->weight; 826 826 } 827 827 if (add) { 828 status = pmModelAdd (target, source->maskObj, model, PM_MODEL_OP_FULL);828 status = pmModelAdd (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 829 829 } else { 830 status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL);830 status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 831 831 } 832 832 … … 834 834 } 835 835 836 bool pmSourceAdd (pmSource *source, pmModelOpMode mode) { 837 bool status = pmSourceOp (source, mode, true); 838 return status; 839 } 840 841 bool pmSourceSub (pmSource *source, pmModelOpMode mode) { 842 bool status = pmSourceOp (source, mode, false); 843 return status; 836 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal) { 837 return pmSourceOp (source, mode, true, maskVal); 838 } 839 840 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal) { 841 return pmSourceOp (source, mode, false, maskVal); 844 842 } 845 843 … … 863 861 if (isPSF) { 864 862 *isPSF = true; 865 }863 } 866 864 return model; 867 865 … … 871 869 if (isPSF) { 872 870 *isPSF = true; 873 }874 return source->modelPSF;871 } 872 return source->modelPSF; 875 873 } 876 874 return (model);
Note:
See TracChangeset
for help on using the changeset viewer.
