22 namespace afwGeom = lsst::afw::geom;
24 namespace afwDetect = lsst::afw::detection;
25 namespace pexLog = lsst::pex::logging;
26 namespace pexExcept = lsst::pex::exceptions;
33 template <
typename PixelT>
39 _footprints(std::vector<lsst::afw::detection::
Footprint::
Ptr>()) {
42 for (std::vector<std::string>::iterator mi = detBadMaskPlanes.begin();
43 mi != detBadMaskPlanes.end(); ++mi){
47 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection",
48 "Cannot update bad bit mask with %s", (*mi).c_str());
49 pexLog::TTrace<7>(
"lsst.ip.diffim.KernelCandidateDetection",
53 pexLog::TTrace<4>(
"lsst.ip.diffim.KernelCandidateDetection",
77 template <
typename PixelT>
84 int fpNpixMin = _policy.getInt(
"fpNpixMin");
85 int fpGrowPix = _policy.getInt(
"fpGrowPix");
87 bool detOnTemplate = _policy.getBool(
"detOnTemplate");
88 double detThreshold = _policy.getDouble(
"detThreshold");
89 std::string detThresholdType = _policy.getString(
"detThresholdType");
95 boost::shared_ptr<std::vector<afwDetect::Footprint::Ptr> > footprintListInPtr;
101 if (detOnTemplate ==
true) {
103 *(templateMaskedImage),
110 pexLog::TTrace<4>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
111 "Found %d total footprints in template above %.3f %s",
112 footprintListInPtr->size(), detThreshold, detThresholdType.c_str());
116 *(scienceMaskedImage),
122 pexLog::TTrace<4>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
123 "Found %d total footprints in science image above %.3f %s",
124 footprintListInPtr->size(), detThreshold, detThresholdType.c_str());
128 for (std::vector<afwDetect::Footprint::Ptr>::iterator i = footprintListInPtr->begin();
129 i != footprintListInPtr->end(); ++i) {
131 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
132 "Processing footprint %d", (*i)->getId());
133 growCandidate((*i), fpGrowPix, templateMaskedImage, scienceMaskedImage);
136 if (_footprints.size() == 0) {
138 "Unable to find any footprints for Psf matching");
141 pexLog::TTrace<1>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
142 "Found %d clean footprints above threshold %.3f",
143 _footprints.size(), detThreshold);
147 template <
typename PixelT>
154 int fpNpixMax = _policy.getInt(
"fpNpixMax");
170 if (fp->getNpix() > fpNpixMax) {
171 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
172 "Footprint has too many pix: %d (max =%d)",
173 fp->getNpix(), fpNpixMax);
180 return growCandidate(fpCore, fpGrowPix, templateMaskedImage, scienceMaskedImage);
183 pexLog::TTrace<8>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
184 "Original footprint in parent : %d,%d -> %d,%d -> %d,%d",
214 pexLog::TTrace<8>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
215 "Grown footprint in parent : %d,%d -> %d,%d -> %d,%d",
224 if (!(templateMaskedImage->getBBox().contains(fpGrowBBox))) {
225 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
226 "Footprint grown off image");
231 bool subimageHasFailed =
false;
238 if (fsb.
getBits() & _badBitMask) {
239 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
240 "Footprint has masked pix (vals=%d) in image to convolve",
242 subimageHasFailed =
true;
246 if (fsb.
getBits() & _badBitMask) {
247 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
248 "Footprint has masked pix (vals=%d) in image not to convolve",
250 subimageHasFailed =
true;
254 pexLog::TTrace<6>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
255 "Exception caught extracting Footprint");
256 pexLog::TTrace<7>(
"lsst.ip.diffim.KernelCandidateDetection.apply",
258 subimageHasFailed =
true;
260 if (subimageHasFailed) {
264 _footprints.push_back(fpGrow);
Image Subtraction helper functions.
An include file to include the header files for lsst::afw::geom.
lsst::pex::policy::Policy _policy
a container for holding hierarchical configuration data in memory.
definition of the Trace messaging facilities
StringArray getStringArray(const std::string &name) const
void apply(MaskT const &mask)
void apply(MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage)
Runs Detection on a single image for significant peaks, and checks returned Footprints for Masked pix...
A Threshold is used to pass a threshold value to detection algorithms.
Detect candidates for kernels within 2 images.
KernelCandidateDetection(lsst::pex::policy::Policy const &policy)
lsst::afw::image::MaskPixel _badBitMask
Class to accumulate Mask bits.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
MaskT::Pixel getBits() const
An include file to include the header files for lsst::afw::image.
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
An include file to include the header files for lsst::afw::detection.
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
Search through images for Footprints with no masked pixels.
A class to manipulate images, masks, and variance as a single object.
bool growCandidate(lsst::afw::detection::Footprint::Ptr fp, int fpGrowPix, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage)
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Threshold createThreshold(const double value, const std::string type="value", const bool polarity=true)
Factory method for creating Threshold objects.
virtual char const * what(void) const
#define LSST_EXCEPT(type,...)
lsst::afw::detection::Footprint Footprint
boost::shared_ptr< KernelCandidateDetection > Ptr
boost::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > MaskedImagePtr